Home > Backend Development > PHP Tutorial > PHP+AjAx implements progress bar RadyState states_PHP tutorial

PHP+AjAx implements progress bar RadyState states_PHP tutorial

WBOY
Release: 2016-07-21 14:54:39
Original
922 people have browsed it

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 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 some data in the response can be called

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 browsers

}

}

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
}

}

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364548.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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template