开发者社区 问答 正文

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

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

展开
收起
a123456678 2016-03-11 13:12:36 1978 分享 版权
1 条回答
写回答
取消 提交回答
  • 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();前面

    2019-07-17 18:58:59
    赞同 展开评论
问答地址: