87,955
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
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;
}
function sendPHP(msg)
{
//用2个xmlHttp分别向2个php文件发送并返回信息
}
setInterval("sendPHP('msg')",1000);