Skip to content

Instantly share code, notes, and snippets.

@grahul
Created March 9, 2014 15:30
Show Gist options
  • Select an option

  • Save grahul/9449448 to your computer and use it in GitHub Desktop.

Select an option

Save grahul/9449448 to your computer and use it in GitHub Desktop.

Revisions

  1. grahul created this gist Mar 9, 2014.
    21 changes: 21 additions & 0 deletions ajaxSetup
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    $(function() {
    $.ajaxSetup({
    error: function(jqXHR, exception) {
    if (jqXHR.status === 0) {
    alert('Not connect.\n Verify Network.');
    } else if (jqXHR.status == 404) {
    alert('Requested page not found. [404]');
    } else if (jqXHR.status == 500) {
    alert('Internal Server Error [500].');
    } else if (exception === 'parsererror') {
    alert('Requested JSON parse failed.');
    } else if (exception === 'timeout') {
    alert('Time out error.');
    } else if (exception === 'abort') {
    alert('Ajax request aborted.');
    } else {
    alert('Uncaught Error.\n' + jqXHR.responseText);
    }
    }
    });
    });