Ajax.html
<! DOCTYPE html>
check.php
<?php
$username = $_get[' username ');
$password = $_get[' password ');
if ($username = = ' 1 ' && $password = = ' 1 ') {
echo 2;
} else {
echo 1;
}
? >
XMLHttpRequest status = 0 issue.
Xmlhttp.readystate =4 The time, has been xmlhttp.status. = 200. Then the output, found in the Xmlhttp.status=0,http protocol but not the status code. Finally turn over Ah, find AH find Ah, finally found a XMLHttpRequest description: http://www.w3.org/TR/XMLHttpRequest/.
The status attribute must return the result of running these steps:
The value of status must return the result of running these steps.
1, if the state is unsent or opened, return 0. (If the status is unsent or opened, return 0)
2, if the error flag is set, return 0. (If the error label is set, return 0)
3. Return the HTTP status code.
If both of these cases occur before HTTP is returned, 0 is present.
First say two button, one is the URL is: file:///E:/test2.html, the other is: http://www.baidu.com.
The first button URL access is only local open not through the server, you can use Wireshark to catch the package (thanks to some expert pointing).
There is another problem in this, that is, xmlhttp.readystate will always change,
1: Server Connection established
2: Request received
3: In Request processing
4: The request is complete and the response is ready.
In this case, it should be XMLHTTP himself in the simulation, because there is no server. Open directly locally. Opened, so the status is 0.
The second button has URL access, although it is a different domain name, the catch is there, but this is a cross-domain access,
If The Cross-origin request status is network error
This is a network error.
Although go to visit, should be browser cross-domain return header is not allowed, so browser block,??????? Access-control-allow-origin this property.
The actual method is to access the URL within the domain of your own server.