Skip to content Skip to sidebar Skip to footer

Ajax Not Handling 302 Redirect

I have a database on an external server that I am trying to query. To do this, I am going on my local server (Tomcat) and creating an AJAX call (just the XMLHttpRequest object - I

Solution 1:

Since it's an ajax request you can't pull data from another domain: http://en.wikipedia.org/wiki/Same_origin_policy

All you can do here really is request data from your own server (same domain) and have it pull data from the external db for you.

edit: this response is over 3 years old and now with modern browsers (not IE < 10) you can use Cross Origin Resource Sharing - https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

Solution 2:

You have a syntax error readystate needs to be readyState. The way it is written, it will never be 4.

Another piece of advice would be to just check for a readyState of 4 and within that statement test for the status of 302. That way you will be able to troubleshoot whether or not it is the 302 that is causing your issue.

Solution 3:

Try to do the redirection on the server side

Snapshot from FireBug

See this snapShot

In this snapshot the Ajax request sent to server side (where there is the redirection)

Post a Comment for "Ajax Not Handling 302 Redirect"