Description of the returned value of XMLHTTP. Status in Ajax is not 200

Source: Internet
Author: User

Source: http://www.fcgood.com/Program/AJAX/3562.html

 

Why is XMLHTTP. status not 200 in Ajax?

In Ajax, the status attribute of the XMLHTTPRequest object is generally used to return the HTTP status code of the server. Status 200 indicates "successful", and status 404 indicates "Page not found ". Many books are written in this way, which is not bad at all.

However, sometimes, especially when learning Ajax, the Code may run directly locally. In this case, the problem occurs. If you run locally (for example, c: \ Ajax \ helloworld.htm), the status attribute returns 0 if it is "successful" or "not found on the page, instead of 200 and 404. At this time, if you still use if (XMLHTTP. Status = 200) to judge the operation, there will be no results. If you want to test it locally, you 'd better write it as if (XMLHTTP. Status = 200 | XMLHTTP. Status = 0.

As I mentioned earlier, this does not mean that many books or articles are wrong. Because all these articles write the status returned from the server, but they do not say that the returned status from the local server is missing.

Related Article

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.