This might help you. In process of editing your fiddle.
$.ajax({
statusCode: {
404: function() {
alert("page not found");
}
}
});
EDIT: I tweaked your .fail()
function to handle multiple response status codes collectively (I think this should serve what you were looking for). FIDDLE
.fail(function (response) {
if ($.inArray(response.status, [404, 302, 502]) != -1) {
$('pre').append("My callback fired, ");
} else {
$('pre').append("oops, error? ");
}
})