Accessing XMLHttpRequest from the success ajax event in jQuery
According to the doc, the 'error' ajax event gets passed the XMLHttpRequest object, 'success' does not.
http://docs.jquery.com/Ajax/jQuery.ajax
That's a shame, because I would like to be able to access the HTTP status code in success. I am doing so successfully with 开发者_运维技巧error.
error: function(data){
alert(data.status)
}
Any leads would be great.
Thank you.
You would be looking for the complete() callback in this case, which occurs after success:
// A function to be called when the request finishes
// (after success and error callbacks are executed).
// The function gets passed two arguments: The
// XMLHttpRequest object and a string describing the
// type of success of the request. This is an Ajax Event.
complete: function (XMLHttpRequest, textStatus) {
this; // the options for this ajax request
}
精彩评论