More Than Five
More Than Five

Reputation: 10419

302 from an AJAX request

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

Upvotes: 1

Views: 905

Answers (1)

Jules
Jules

Reputation: 1747

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.

Upvotes: 2

Related Questions