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.