Under what circumstances will Ajax go success and error

Source: Internet
Author: User

Simply put, the AJAX request sends a request through the XMLHttpRequest object, which has four states (ReadyState):

0-Uninitialized, 1-initializing, 2-sending data, 3-sending data, 4-complete.

When Xmlhttprequest.readystate is 4 o'clock, it indicates that the AJAX request has been completed to get the response result.

The success and error methods of Ajax are triggered according to the response status code. When Xmlhttprequest.status is 200, the response is successful and success () is triggered. Other Status Codes trigger error ().

In addition to the response status code, AJAX will take the error method in the following cases:

1. The return data type does not match the datatype

2. Network outages

3. Background response interruption

Under what circumstances will Ajax go success and error

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.