Ajax + php build progress bar readyState various statuses _ PHP Tutorial

Source: Internet
Author: User
Ajax + php creates the readyState status of the progress bar. Creating a progress bar with Ajax + php is actually very simple. ReadyState status (, 4) 0: The request has not been initialized, open1 has not been called: The request has been created, but has not been sent, and send has not been called to create a progress bar using Ajax + php, it 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

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

Bytes. ReadyState = status (0, 1, 2, 3, 4) 0: The request has not been initialized and open 1 has not been called. the request has been created, but has not been sent. the send...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.