1

I send an AJAX request which returns a 302 (I see this using fiddler) but in firebug I never see the 302. I just see a 500.

Same thing happens with IE.

If an AJAX request returns a 302 do browsers swallow it?

Thanks

More Than Five
  • 9,959
  • 21
  • 77
  • 127
  • They certainly won't swallow it, I'm not sure they can make a bird out of a http response... – sg3s Apr 23 '13 at 10:41
  • I do not think that an AJAX call will perform the recursive lookup/redirect that happens with a normal browser response to a standard 302 ... – Silvertiger Apr 23 '13 at 10:44
  • I fail at selecting the correct link; this is probably a duplicate of http://stackoverflow.com/questions/2770289/how-to-catch-an-expected-and-intended-302-ajax-response – sg3s Apr 23 '13 at 10:51

1 Answers1

2

When performing an AJAX POST in my web application, I found that my browser was registering a 302 Found, followed by a 200 OK.

Browser network inspector

However, the JavaScript debugger showed the response as being a 200 OK, with the HTML content to be shown on the redirection page.

Browser JavaScript inspector

This demonstrates that the redirection is being handled internally by JavaScript. In this case, you could replace the page's content with that returned by the server's response.

document.open();
document.write(xhr.responseText);
document.close();

See this question for more details.

Community
  • 1
  • 1
Jules
  • 1,677
  • 1
  • 19
  • 25