首页 >后端开发 >php教程 >ajax技术 始终出去发送状态,该如何解决

ajax技术 始终出去发送状态,该如何解决

WBOY
WBOY原创
2016-06-13 11:49:24766浏览

ajax技术始终向外发送状态
ajax.js代码:
       var xmlHttp;
function S_xmlhttprequest(){
    if(window.ActiveXObject){
       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP ");
    }
    else if(widow.XMLHttpRequest){
       xmlHttp=new XMLHttpRequest();
    }
}
函数 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代码:
          238d2ec7bf242afcc07025c8c15667982cacc6d41bbb37262a98f745aa00fbf0
3565d276354df801b63e1d0387a99befoe251e3a278821fafa8c46524d8cf26b6x5db79b134e9f6b82c0b36e0489ee08ed
0c6dc11e160d3b678d68754cc175188a
d5608ceef33210b5638975faf2a1861716b28748ea4df4d9c2150843fecfba68
--------解决方案-- ------------------

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

<html><br /><head><br />	<title> </title>	<br />	<script type="text/javascript" src='jquery-1.4.2.min.js'></script><br /><br /></head><br /><script type="text/javascript"><br />	var xmlHttp;<br />	function S_xmlhttprequest(){<br />		if(window.ActiveXObject){<br />			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");<br />		}<br />		else if(window.XMLHttpRequest){<br />			xmlHttp=new XMLHttpRequest();<br />		}<br />	}<br />	function funphp100(url){<br />		S_xmlhttprequest();<br />		xmlHttp.open("GET","test.php?id="+url,true);<br />		xmlHttp.onreadystatechange=byphp;<br />		xmlHttp.send(null);<br />	}<br />	function byphp(){<br />		if(xmlHttp.readyState==1){<br />			document.getElementById('php100').innerHTML="loading....";<br />		}<br />		if(xmlHttp.readyState==4){<br /><br />			var byphp100 = xmlHttp.responseText;<br />			document.getElementById('php100').innerHTML=byphp100;<br /><br />		}<br /><br />	}<br /><br /></script><br /><body><br />	<a href= "#" onclick="funphp100('o')">o</a><br />	<a href= "#" onclick="funphp100('t')">t</a><br />	<a href= "#" onclick="funphp100('x')">x</a><br />	<br><br />	<div id="php100"></div><br /></body><br /></html>


----- -解决方案--------------------
else if(widow.XMLHttpRequest){
       xmlHttp=new XMLHttpRequest ();
    }
窗口

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn