Skip to content

Instantly share code, notes, and snippets.

@garystorey
Created May 7, 2013 15:58
Show Gist options
  • Select an option

  • Save garystorey/5533753 to your computer and use it in GitHub Desktop.

Select an option

Save garystorey/5533753 to your computer and use it in GitHub Desktop.
Error messages for $.ajaxsetup
$.ajaxSetup({
error: function(jqXHR, exception) {
var msg='';
if (jqXHR.status === 0) {
msg='Not connected.\n Verify Network Connectivity.';
} else if (jqXHR.status == 404) {
msg='Requested page not found. [404]';
} else if (jqXHR.status == 500) {
msg='Internal Server Error [500]';
} else if (exception === 'parsererror') {
msg='Requested JSON parse failed.';
} else if (exception === 'timeout') {
msg='Time out error.';
} else if (exception === 'abort') {
msg='Ajax request aborted.';
} else {
msg='Uncaught Error.\n' + jqXHR.responseText;
}
if (msg) {
console.log(msg);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment