我的setInterval启动了,但XMLHttpRequest();
似乎没有通过?
我得到了第一个console.log()
,但没有第二个。
对此的任何见解都将不胜感激。
代码如下:
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);
发布于 2014-12-26 17:28:02
你需要做jsonrequestIntervaled.send();
才能打电话
https://stackoverflow.com/questions/27659974
复制相似问题