Check out jQuery.ajaxError()
It catches global Ajax errors which you can handle in any number of ways:
if (jqXHR.status == 500) {
// Server side error
} else if (jqXHR.status == 404) {
// Not found
} else if {
...
Alternatively, you can create a global error handler object yourself and choose whether to call it:
function handleAjaxError(jqXHR, textStatus, errorThrown) {
// do something
}
$.ajax({
...
success: function() { ... },
error: handleAjaxError
});