0

I'm using Google Closure's Xhrio facilities to send a POST request to a URL. When the response to this request is a 302 redirect, I'd like to redirect the user's browser to the URL being redirected to.

I've tried calling getLastUri on the object passed to the callback, but that returns the URI of the request, rather than that of the subsequent redirection. getStatus returns 200. I know that the request is being properly redirected, because I can see it in Chrome's Network request viewer.

Matthew H
  • 5,831
  • 8
  • 47
  • 82

1 Answers1

0

The temporary redirect (302) is probably handled by the browser, and javascript never gets to see it.

We also had a similar problem, and I just solved it by modifying the server side code to send a 401 instead of 302 on encountering a certain header (X-HTTP-Method-Override) which you will have to explicitly set in your request. The server response can include the redirection url in the response (along with the 401 status).

This stackoverflow question illustrates the server side changes: "Cannot handle 302 redirect in ajax and why?"

Community
  • 1
  • 1
SpeedySan
  • 572
  • 4
  • 10