getElementsByTagName问题求解
<html><br /><head><br /><br /><?php<br /> $username=$_GET['username'];<br /> $username=trim($username);//去掉空格<br /> session_start();<br /> $loginuser=$_SESSION['loginuser'];<br />?><br /><br /><meta http-equiv="content-type" content="text/html;charset=utf-8"/><br /><script src="my.js"></script><br /><script><br /> window.resizeTo(500,400);<br /><br /><br /> window.setInterval("getMessage()",5000);<br /> <br /> function getMessage(){ <br /> var myXmlHttpRequest=getXmlHttpObject();<br /> if(myXmlHttpRequest){ <br /> var url="GetMessageControl.php";<br /> var data="getter=<?php echo $loginuser; ?>&sender=<?php echo $username; ?>";<br /> myXmlHttpRequest.open("post",url,true);<br /> myXmlHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");<br /> //重点。指定处理结果的 函数<br /> myXmlHttpRequest.onreadystatechange=function (){<br /> if(myXmlHttpRequest.readyState==4){<br /> if(myXmlHttpRequest.status==200){<br /> var mesRes=myXmlHttpRequest.responseXML;<br /> var cons=mesRes.getElementsByTagName("con");<br /> var sendTimes=mesRes.getElementsByTagName("sendTime");<br /> window.alert(cons.length);<br /> if(cons.length!=0){<br /> for(var i=0;i<cons.length;i++){<br /> $('mycons').value+="<?php echo $username; ?>对<?php echo $loginuser; ?>说:"+cons[i].childNodes[0].nodeValue+" "+sendTimes[i].childNodes[0].nodeValue; <br /> <br /> }<br /> }<br /> }<br /> }<br /> <br /> }<br /> myXmlHttpRequest.send(data);<br /><br /><br /> }<br /> <br /> }<br /><br /><br /><br /> function sendMessage(){<br /> var myXmlHttpRequest=getXmlHttpObject();<br /><br /> if(myXmlHttpRequest){<br /> var url="SendMessageControl.php";<br /> //js中使用php数据<br /> var data="con="+$('con').value+"&getter=<?php echo $username; ?>&sender=<?php echo $loginuser; ?>";<br /> window.alert(data);<br /> <br /> myXmlHttpRequest.open("post",url,true);<br /> myXmlHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");<br /> myXmlHttpRequest.onreadystatechange=function (){<br /> if(myXmlHttpRequest.readyState==4){<br /> if(myXmlHttpRequest.status==200){<br /> <br /> }<br /> }<br /> <br /> }<br /> myXmlHttpRequest.send(data);<br /> }<br /> <br /> }<br /></script><br /></head><br /><br /><br /><br /><center><br /><h1>聊天室(您正在和<font color="red"><?php echo $username; ?></font>聊天)</h1><br /> <textarea cols="30" rows="10" id="mycons"></textarea><br><br /> <input type="text" style="width:200px" id="con"><br /> <input type="button" value="send" onclick="sendMessage()"><br /><br /><br /><br /></center><br /><br /></html><br />
dfb36fcd599d88b473a5121b2813d41bexecute_dml($sql);<br> <br> <br> <br> }<br> //获取信息,并把数据组装好返回给客户端(聊天室)<br> function getMessage($getter,$sender){<br> $sql="select * from message where getter='$getter' and sender='$sender' and isGet=0";<br> <br><br> $sqlHelper=new SqlHelper();<div class="clear"></div>