时间:2021-07-01 10:21:17 帮助过:1人阅读
var counter = xmlHttp.responseXML.getElementsByTagName("count")[0].firstChild.data;
var counter = xmlHttp.responseXML.getElementsByTagName("count")[0].firstChild.data;
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;
}
pollServer() 中调用counter() 要放到 createXMLHttpRequest();前面
可以通过使用PHP的XMLReader
内置类获取
http://www.gxlcms.com/article/80437.htm
两种方法 一:解析XML 二:正则匹配