javascript - 请教个问题,这里的这个1怎么获取呀
本文介绍了javascript - 请教个问题,这里的这个1怎么获取呀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
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();前面
这篇关于javascript - 请教个问题,这里的这个1怎么获取呀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文