<code> var counter = xmlHttp.responseXML.getElementsByTagName("count")[0].firstChild.data;</code><code> var counter = xmlHttp.responseXML.getElementsByTagName("count")[0].firstChild.data;</code>
<code>function startCallback(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
setTimeout("pollServer()",5000);
refreshTime();
}
}
}
function pollServer(){
var url = "DynamicUpdateServlet.php?task=foo" + counter();
createXMLHttpRequest();
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange = pollCallback;
xmlHttp.send(null);
}
function counter(){
var res = "&counter=";
var count = xmlHttp.responseXML.getElementsByTagName("count")[0].firstChild.data;
res += count;
return res;
}
</code>pollServer() 中调用counter() 要放到 createXMLHttpRequest();前面
可以通过使用PHP的XMLReader内置类获取
http://www.jb51.net/article/80437.htm
立即学习“Java免费学习笔记(深入)”;
两种方法 一:解析XML 二:正则匹配
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号