Home > Backend Development > PHP Tutorial > javascript - 请教个问题,这里的这个1怎么获取呀

javascript - 请教个问题,这里的这个1怎么获取呀

WBOY
Release: 2016-06-06 20:11:38
Original
1125 people have browsed it

javascript - 请教个问题,这里的这个1怎么获取呀

<code>            var counter = xmlHttp.responseXML.getElementsByTagName("count")[0].firstChild.data;</code>
Copy after login
Copy after login

回复内容:

javascript - 请教个问题,这里的这个1怎么获取呀

<code>            var counter = xmlHttp.responseXML.getElementsByTagName("count")[0].firstChild.data;</code>
Copy after login
Copy after login

<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>
Copy after login

pollServer() 中调用counter() 要放到 createXMLHttpRequest();前面

可以通过使用PHP的XMLReader内置类获取

http://www.jb51.net/article/80437.htm

两种方法 一:解析XML 二:正则匹配

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template