Created
May 7, 2013 15:58
-
-
Save garystorey/5533753 to your computer and use it in GitHub Desktop.
Error messages for $.ajaxsetup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.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