Php+ajax implementing progress bar radystate each state _php tutorial

Source: Internet
Author: User
Using ajax+php to create a progress bar is actually very simple.

ReadyState = = Status (0,1,2,3,4)

0: The request was not initialized and the open was not called

1: The request has been established, but has not yet been sent, and the send has not been called

2: The request has been sent and is being processed

3: The request is being processed, and a portion of the data in the response is usually callable

4: Complete

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 an asynchronous transfer

Xmlhttp.onreadystatechange = ip985;//response function

Xmlhttp.send (NULL);

}

function ip985 ()

{

if (xmlhttp.readystate==1)

{

document.getElementById (' IP985 '). InnerHTML = "Request established, ready to send ..."; IP985 flag bit

}

if (xmlhttp.readystate==4)
{
var v = xmlhttp.responsetext;//Get content

document.getElementById (' ip985 '). InnerHTML = v;//target page content
}

}

Source: 5D Happy blog: http://www.5DKX.com/

http://www.bkjia.com/PHPjc/364548.html www.bkjia.com true http://www.bkjia.com/PHPjc/364548.html techarticle using ajax+php to create a progress bar is actually very simple. ReadyState = = Status (0,1,2,3,4) 0: Request not initialized, open 1 not yet called: the request has been established, but has not yet been sent, not yet called 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.