The general error function returns three parameters: function (jqxhr jqxhr, String textstatus, String errorthrown). The common calling code is as follows:
$.ajax ({ '/home/ajaxgetdata ', function (data) { alert (data); }, function (JQXHR, Textstatus, Errorthrown) { /* error handling */ } } );
These three parameters are described in detail here.
The first parameter jqxhr jqxhr: Here the JQXHR is a Jqxhr object, The XMLHttpRequest object was returned before the Jquery1.4 and 1.4 versions, and after version 1.5 The JQXHR object is used, which is a superset of the object that includes not only the XMLHttpRequest object, but also more detailed properties and information.
There are 4 main properties here:
- ReadyState: Current state, 0-uninitialized, 1-loading, 2-loaded, 3-data interacting, 4-completed.
- Status: The HTTP status code returned, such as a common 404,500 error code.
- StatusText: the error message corresponding to the status code, such as the 404 error message is not found,500 is internal Server error.
- ResponseText: The text message returned by the server response
The second parameter, string textstatus: Returns a String type that represents the returned state, depending on the server error may return the following information: "Timeout" (timeout), "error" (fault), "Abort" (abort), " ParserError "(parse error), and it is possible to return a null value.
The third parameter, string Errorthrown: is also a string type, indicating that the server throws the returned error message, if the resulting HTTP error, then the information returned is the HTTP status code corresponding error message, such as 404 Not Found, 500 wrong internal Server error.
Example code:
$.ajax ({url: '/ajax requested URL '
Ten has three
Source: http://shiyousan.com/post/635433082130309661
JQuery Ajax Error function parameters (acquisition of interactive error information)