Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8037257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:52:33+00:00 2026-06-05T02:52:33+00:00

I want to redirect to the target using the Location header with jQuery 1.7.

  • 0

I want to redirect to the target using the Location header with jQuery 1.7.

My code looks like this

$('#creationLink').click(function(){
  $.ajax({
    type: 'POST',
    url: '/',
    success: function(data, textStatus, xhr) {
      window.location = xhr.getResponseHeader("Location");
    }
  })
});

… but it does not work. xhr.getResponseHeader("Location") is null.

HTTP headers:

POST / HTTP/1.1
Host: localhost:9000
X-Requested-With: XMLHttpRequest
Content-Length: 0

HTTP/1.1 302 Found
Content-Type: text/plain; charset=utf-8
Location: http://localhost:9000/vIRdD0PdWp4/bearbeiten
Content-Length: 0

How can I redirect using the location header?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:52:35+00:00Added an answer on June 5, 2026 at 2:52 am

    AFAIK, browsers are supposed to, during an XHR, transparently follow the redirect in the response header. That is, the XHR will actually look at the response, see the Location header, and proceed to magically run a second request for that URI. Only when it has the result of that will it give you anything at all, and what it gives you is the result of the second request.

    See this stackoverflow answer!

    So, if you need a redirect feature, you’ll have to make the thing you request return the target URI in some other way, e.g. as a JSON response.

    See this stackoverflow solution!

    PS. reference: http://www.w3.org/TR/XMLHttpRequest/#infrastructure-for-the-send-method

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to redirect one specific url like: www.example.com/test/ex.gif to static.example.com/ex.gif How can i
I want to redirect all requests for index.html|php|php5 to http://www.domain.co.uk/ using mod_rewrite and I've
I am creating application in facebook using iframe. In that i want to redirect
For logging purposes i want to log the redirect target of the current request
I want to redirect only php files and files with no file extension like
I want redirect my getJSON response to another html page below is the code
I have some trouble using an Ajax query in a Rails + JQuery ecosystem.
I want to cause a browser redirect by changing the value of window.location in
Response.Redirect has two overloads: public void Redirect(string url) Parameters: url: The target location. public
Due to multiple scripts I have on the target domain I want to redirect

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.