Redirect After Post Using The Location Header With Jquery
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: '/',
Solution 1:
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.
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.
Seethis stackoverflow solution!
PS. reference: http://www.w3.org/TR/XMLHttpRequest/#infrastructure-for-the-send-method
Post a Comment for "Redirect After Post Using The Location Header With Jquery"