Heim > Artikel > Backend-Entwicklung > javascript - 请教个问题,这里的这个1怎么获取呀
<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
两种方法 一:解析XML 二:正则匹配