Using Ajax+php to create a progress bar is actually very simple.
readyState == status (0,1,2,3,4)
0: The request has not been initialized, open has not been called yet
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 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 content
document.getElementById('ip985').innerHTML = v;//Target web page content
}
}
http://www.bkjia.com/PHPjc/321494.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321494.htmlTechArticleUsing Ajax+php to create a progress bar is actually very simple. readyState == status (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 it has not been sent, and send has not been called yet...
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