Home >Backend Development >PHP Tutorial >Ajax+php creates progress bar code [readyState description of each status]_PHP tutorial

Ajax+php creates progress bar code [readyState description of each status]_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:39:26898browse

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
}
}

www.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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn