How can I solve the problem of ajax technology always sending status?

Source: Internet
Author: User
Ajax technology always sends out the status ajax. js code: & nbsp; var & nbsp; xmlHttp; function & nbsp; S_xmlhttprequest () {& nbs ajax technology always goes out of the sending status
Ajax. js code:
Var xmlHttp;
Function S_xmlhttprequest (){
If (window. ActiveXObject ){
XmlHttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Else if (widow. XMLHttpRequest ){
XmlHttp = new XMLHttpRequest ();
}
}
Function funphp100 (url ){
S_xmlhttprequest ();
XmlHttp. open ("GET", "for. php? Id = "+ url, true );
XmlHttp. onreadystatechange = byphp;
XmlHttp. send (null );
}
Function byphp (){
If (xmlHttp. readyState = 1 ){
Document. getElementById ('php100'). innerHTML = "loading ....";
}
If (xmlHttp. readyState = 4 ){

Var byphp100 = xmlHttp. responseText;
Document. getElementById ('php100'). innerHTML = byphp100;

}

}
For. php code
If ($ id = $ _ GET [id]) {
For ($ I = 1; $ I <= 5; $ I ++ ){

Echo $ I;
Sleep (2 );
}
Exit ();
}
?>
Index. php code:
Script
O
T
X



------ Solution --------------------
if($id=$_GET[id]){
  for($i=1;$i<=5;$i++){

echo $i;
//sleep(2);
   }
   exit();
}



 
《script》



var xmlHttp;
function S_xmlhttprequest(){
if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
}
function funphp100(url){
S_xmlhttprequest();
xmlHttp.open("GET","test.php?id="+url,true);
xmlHttp.onreadystatechange=byphp;
xmlHttp.send(null);
}
function byphp(){
if(xmlHttp.readyState==1){
document.getElementById('php100').innerHTML="loading....";
}
if(xmlHttp.readyState==4){

var byphp100 = xmlHttp.responseText;
document.getElementById('php100').innerHTML=byphp100;

}

}

《script》

o
t
x






------ Solution --------------------
Else if (widow. XMLHttpRequest ){
XmlHttp = new XMLHttpRequest ();
}
Window

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.