JQuery Ajax Error function parameters (acquisition of interactive error information)

Source: Internet
Author: User
Tags parse error

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.