首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >XMLHttpRequest() SetInterval

XMLHttpRequest() SetInterval
EN

Stack Overflow用户
提问于 2014-12-26 17:24:56
回答 1查看 2.7K关注 0票数 4

我的setInterval启动了,但XMLHttpRequest();似乎没有通过?

我得到了第一个console.log(),但没有第二个。

对此的任何见解都将不胜感激。

代码如下:

代码语言:javascript
运行
复制
var countdown = 1000;
var region = "the_Pacific";
var jsonrequestInterval = function () {
    console.log("The clock was updated");
    var jsonrequestIntervaled = new XMLHttpRequest();
    jsonrequestIntervaled.open("GET", 'myURL' + region, true);
    jsonrequestIntervaled.onreadystatechange = function () {
        if (jsonrequestIntervaled.readyState == 4) {
            console.log("The request was made");
            if (clock.getTime() >= jsonrequestIntervaled.responseText.match(/-?[1-9]\d+/g)) {
                clock.setTime(jsonrequestIntervaled.responseText.match(/-?[1-9]\d+/g));
            }
            if (time > 300) {
                countdown = 10000;
            } else if (time < 60) {
                countdown = 1000;
            } else if (time < 300) {
                countdown = 5000;
            }
        }
    };
};
//problem not updating!!!!!!!!!!!!!!!!!!!!!
setInterval(jsonrequestInterval, countdown);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-26 17:28:02

你需要做jsonrequestIntervaled.send();才能打电话

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27659974

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档