The code looks a little something like this:
$.get('url', function() {
alert("success");
})
.error(function() {
alert("error");
})
Another snazzy way of dealing with error handling
$.get("url")
.done(function(){
alert("success");
})
.fail(function(){
alert("error(fail)");
});
You could also use the .ajaxError() method, which involves too much prep work for my taste.
.ajaxError() example:
$(document).ajaxError(function(e, xhr, settings, exception) {
alert("error");
});
I find that the $.get().error() chaining method is more efficient as it involves the least amount of lines of code. And when you’re working with the mobile web, every line counts.