Home > Backend Development > PHP Tutorial > ajax技术 始终出去发送状态

ajax技术 始终出去发送状态

WBOY
Release: 2016-06-23 14:01:45
Original
782 people have browsed it

ajax.js代码:
       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代码
           if($id=$_GET[id]){
  for($i=1;$i
echo $i;
sleep(2);
   }
   exit();
}
?>
index.php代码:
          <script></script>
o
t
x



回复讨论(解决方案)

if($id=$_GET[id]){  for($i=1;$i<=5;$i++){echo $i;//sleep(2);   }   exit();}
Copy after login

<html><head>	<title> </title>		<script type="text/javascript" src='jquery-1.4.2.min.js'></script></head><script type="text/javascript">	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><body>	<a href= "#" onclick="funphp100('o')">o</a>	<a href= "#" onclick="funphp100('t')">t</a>	<a href= "#" onclick="funphp100('x')">x</a>	<br>	<div id="php100"></div></body></html>
Copy after login

我那个哪里出现问题了?

else if( widow.XMLHttpRequest){
       xmlHttp=new XMLHttpRequest();
    }
window

谢谢~~~~~~~~~~~

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