Methods Xhr.readystate of five states
Xhr.readystate = = Status (0,1,2,3,4) 0: The request was not initialized and open () was not called. 1: The request has been established, but has not been sent yet, and the Send () has not been called. 2: The request has been sent, is in process (usually can now get the content header from the response). 3: The request is in process, and some of the data in the response is usually available, not all completed. 4: The response is complete; you can get and use the server's response. Methods Xhr.status Common states Xhr.status = = 200,300,404 100--customers must continue to make requests 101--customer requests that the server convert the HTTP protocol version on request
200--successful 201--prompt to know the URL of the new file
300--requested resource can get 301--delete request data in multiple places
404--no file, query, or URL 500--server generated an internal error index.php
o T X
for.php
For (Echo
"; Sleep (1);
var xmlHttp; function S_xmlhttprequest () {if (window. ActiveXObject) {xmlHttp = new ActiveXObject (' Microsoft.XMLHTTP ');} else if (window. XMLHttpRequest) {xmlHttp = new XMLHttpRequest ();}}
function funphp100 (URL) {s_xmlhttprequest (); Xmlhttp.open ("GET", "for.php?id=" +url,true); Xmlhttp.onreadystatechange = byphp; Xmlhttp.send (NULL); }
function byphp () {
if (xmlhttp.readystate = = 1) {document.getelementbyidx_x (' php100 '). InnerHTML = "Loading ....";}
if (xmlhttp.readystate = = 4) {if (Xmlhttp.status = =) {var byphp100 = Xmlhttp.responsetext; document.getelementbyidx_x ( ' php100 '). InnerHTML = byphp100; } }
}