readyState == state (0,1,2,3,4)
0: The request has not been initialized and open has not been called yet
1: The request has been established but has not been sent yet and send has not been called yet
2 : The request has been sent and is being processed
3: The request is being processed, usually there is already some data in the response that can be called
4: Completed
Copy code The code is as follows:
var xmlHttp;
function create()
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP" );//IE browser
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();//Non-IE browser
}
}
function Request(url)
{
xmlHttp.open("GET","for.php?id="+url,true);//true is asynchronous transmission
xmlHttp.onreadystatechange = ip985 ;//Response function
xmlHttp.send(null);
}
function ip985()
{
if(xmlHttp.readyState==1)
{
document .getElementById('IP985').innerHTML = "The request has been established and is ready to be sent..."; //IP985 flag
}
if(xmlHttp.readyState==4)
{
var v = xmlHttp.responseText;//Get the content
document.getElementById('ip985').innerHTML = v;//Target web page content
}
}
http://www.bkjia.com/PHPjc/321567.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321567.htmlTechArticlereadyState == status (0,1,2,3,4) 0: The request has not been initialized and has not been called yet open 1: The request has been established, but has not been sent, and send has not been called yet. 2: The request has been sent, and is being processed. 3: The request...