javascript - 请教个问题,这里的这个1怎么获取呀
程序员文章站
2022-04-16 21:00:05
...
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.jb51.net/article/80437.htm
两种方法 一:解析XML 二:正则匹配