you can use the following:
dataFilter(data, type)
to intercept the request when it first comes back from the server. This isn't exactly for what you wanted to use it for, but it's a universal pre-success routine.
Pre-Error? maybe a global error handler will work for you?
var obj = {
someHandler: function(data, xmlObj, status) {},
someHandler2: function(data, xmlObj, status) {},
someErrorHandler: function(xmlObj, status, error) {},
someErrorHandler2: function(xmlObj, status, error) {}
}
jQuery.ajax({
success:function(data, xmlObj, status) {
// decide based on data what the run 2nd
if (data.success) {
obj.someHandler(data, xmlObj, status);
}
else {
obj.someHandler2(data, xmlObj, status);
}
},
error: function(xmlObj, status, error) {
// decide based on data what to run 2nd
//same as above.
}
});
I do something similar to this in one of my projects. I have a global Error object, where I execute an error handler based on the TYPE of error that comes back from the server. I found this to be an easy and fast way to create good error handling for AJAX