下面这段代码ff好使,ie不好使,请问该怎么办?function sendPHP(msg)
{
  用2个xmlHttp分别向2个php文件发送并返回信息  setTimeout(function(){sendPHP(msg)},1000);
}

解决方案 »

  1.   

    setTimeout("函数名",时间)
    你先把函数封装好 直接调用
      

  2.   


    function sendPHP(msg)

      //用2个xmlHttp分别向2个php文件发送并返回信息  

    setInterval("sendPHP('msg')",1000);
      

  3.   

    http://book.csdn.net/bookfiles/344/10034413534.shtml
      

  4.   

    setTimeout(sendPHP(msg),1000);
    function sendPHP(msg){
     //...
    }
      

  5.   

     setTimeout(function(){sendPHP(msg)},1000); 
    把函数写外面吧!
      

  6.   

    代码没问题,ie下完全可以这样setTimeout(function(){sendPHP(msg)},1000); 楼主还是检查下ajax请求部分的代码,或者请第一个请求完全结束后(服务器返回200后),在调用下一个.
      

  7.   

    谢谢上面各位朋友,你们的办法我都试了,还是有问题,我做的是聊天室,代码如下,请帮我看看问题在哪?
    6楼说的“(服务器返回200后)”,这句话怎么写?谢谢!function sendPHP(msg){
    url="1.php?name="+name+"&msg="+msg+"&sid="+Math.random(); //对话部分
    xmlHttp_1.onreadystatechange=stateChanged_1;
    xmlHttp_1.open("GET",url,true)
    xmlHttp_1.send(null)
    if(msg!="") {msg=""; editor.body.innerHTML=""; }
     
    url="2.php?name="+name+"&sid="+Math.random();    //在线部分
    xmlHttp_2.onreadystatechange=stateChanged_2;
    xmlHttp_2.open("GET",url,true)
    xmlHttp_2.send(null)setTimeout(function(){sendPHP(msg)},1000);
    }function stateChanged_1(){
    if (xmlHttp_1.readyState==4 || xmlHttp_1.readyState=="complete")
        document.getElementById("show").innerHTML=xmlHttp_1.responseText; 
    }function stateChanged_2(){
    if (xmlHttp_2.readyState==4 || xmlHttp_2.readyState=="complete")
        document.getElementById("person").innerHTML=xmlHttp_2.responseText;
    }
      

  8.   

    if (xmlHttp_1.readyState==4 || xmlHttp_1.readyState=="complete")
        document.getElementById("show").innerHTML=xmlHttp_1.responseText; 
    }换成if (xmlHttp_1.readyState==4)
       if(xmlHttp_1.status==200){
        document.getElementById("show").innerHTML=xmlHttp_1.responseText; 
       }
    }
      

  9.   

    谢谢sundotLei,按照你说的换了,可症状还是那样:
    我在自己的机器上开了几个ff窗口和几个ie窗口,分别以不同的用户名登录,当其中一个用户发帖时,ff窗口的对话立刻自动更新了,可ie窗口的不变,必须刷新它才更新,给我的感觉是
    setTimeout(function(){sendPHP(msg)},1000);那句话不起作用,
    另外是不是我的思路有问题?我是自学,不知道别人的聊天室都是怎样做的,能介绍一下一般的思路吗?