jQuery is the most awesome javascript library that made easy for asynchronous ajax calls.it has global ajax function and some pre defined ajax functions like $.get, $.post, load .etc. but we don’t find any error messages by default with this library. we can see the errors with firefox’s addon firebug or with IE developer toolbar.So we manage most common ajax errors in our application with global ajaxSetup function which come with jQuery by default. We can set many options,to see available ajaxsetup options.
most ajax errors we get errors are server response errors and some JSON parse errors. To know more about the HTTP errors details please check here. To test this error handling just copy and paste it to your head section of HTML document.
Javascript Code for setting global error handling.
|
- 0-xhr status ,is it initialized or not that means user is offline.
- 404-page not found
- 500-Internel Server error.
- request timeout – jQuery custom error.
- parseerror-jQuery custom error when parsing JSON data.
- we just throw other errors with response error
0 comments:
Post a Comment