views:

108

answers:

1

I was looking at this answer and some other answers http://stackoverflow.com/questions/199099/how-to-manage-a-redirect-request-after-a-jquery-ajax-call/199156#199156

I can not get this to work. i check the XMLHttpRequest object in both success and complete. In both cases when there is a redirect instead of getting a 302 i get a 200 and the html for that page. How do i make it actually report the 3xx redirect instead of skipping ahead and giving me a 200?

A: 

The problem most likely lies in your back-end code not returning the correct status. jQuery gives the same status it gets from the back-end so I would start by: posting code for us to see (jQuery and whatever your backend is) and looking at your server logs to see what is happening there.

thenduks
i'll -1 too. Look at the answer linked in comments and the answer with negatives.
acidzombie24
I suppose it serves me right for trying to answer such a poorly asked question. Nevermind.
thenduks
You gave wrong information. "jQuery gives the same status it gets from the back-end". jQuery and redirects do not give you the status of a redirect if it happens. It gives you the status of whatever happens after the redirect. That was the problem with the answer.
acidzombie24
No, if that's what happens then the problem is with your backend. If you render a response with a status code (say in a framework like Rails) you will get a redirect status code in jQuery. I do it all the time.
thenduks
Are you positive? apparently in the standard says it must do it transparently. (comment has a link to a question, this was the solution http://stackoverflow.com/questions/228225/prevent-redirection-of-xmlhttprequest/343359#343359)
acidzombie24