I'm working with the jQuery Form Plugin. I have my servers send 200 responses on success, which trips the 开发者_开发技巧success
listener perfectly fine. Per the standard, 301 and 302 and transparently redirected by the browser. However, when the server returns, say a 401, the Form Plugin just silently dies. How can I apply a listener to non-200 responses?
The XHR will have the responseStatus in it - you can use the complete handler instead of 'success' and check that property of the xhr.
$.ajax({ // ...
complete: function(xhr){
if( xhr.responseStatus == 401 ) {
alert( 'awww crap' );
}
}
});
精彩评论