What part (success/error) of jquery's ajax receives a redirect status code?
I'm having a redirect sent by my server but jquery's ajax error: callback seems to get xhr.status=200
and status="parseerro开发者_运维百科r"
Anywork around?? I don't want to overload other codes since I use the for the things that they were intended for? Is this just not possible with jquery?
The callback is like this:
error: function(xhr, status){...}
When you redirect from the server you can send a response header along with it. And then look for that respone header in the ajax error/success callback. I hope that will help you
var status = xhr.getResponseHeader("redirectResponseHeader");//Specify the same name in the server side code
Now using status
you can decide what to do.
The redirect codes 301, 302, 303, and 307 are handled by the user agent, so you can't access the redirect code from the callback.
Reference: XMLHttpRequest Level 2 spec
精彩评论