My setInterval is firing, but it seems the XMLHttpRequest();
is not going through?
I get the first console.log()
, but not the second.
Any insight into this would be highly appreciated.
Code below:
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);