我的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);
答案 0 :(得分:3)
您需要jsonrequestIntervaled.send();
拨打电话