views:

427

answers:

1

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.

+1  A: 

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
}
cballou