In addition to what @dfsq wrote, you can handle specific status codes:
$.ajax({
statusCode: {
404: function() {
alert( "page not found" );
}
}
});
or with deferred:
$.ajax({
url: "update.php",
type: "POST",
data: customObj
})
.fail(function( jqXHR, textStatus, errorThrown) {
if (jqXHR.status == 403) {
alert( "forbidden" );
}
});
or:
$.ajax({
url: "update.php",
type: "POST",
})
.statusCode({
401: function() { alert( 'Unauthorized' ); },
200: function() { alert( 'OK!'); }
});