Creating a progress bar with Ajax + php is actually very simple.
ReadyState = status (0, 1, 2, 3, 4)
0: the request has not been initialized and open has not been called.
1: The request has been created, but has not been sent yet.
2: The request has been sent and is being processed
3: The request is being processed. Generally, some data in the response can be called.
4: finished
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 indicates asynchronous transmission.
XmlHttp. onreadystatechange = ip985; // Response Function
XmlHttp. send (null );
}
Function ip985 ()
{
If (xmlHttp. readyState = 1)
{
Document. getElementById ('ip985'). innerHTML = "the request has been created 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 webpage content
}
}
Initial: http://www.5dkx.com/arch/107.html
Non-special instructions are original articles such as reprint, please note: reprint from 5D happy blog [http://www.5DKX.com/]