1 回答
TA贡献1828条经验 获得超4个赞
在您的上一个代码中,您将whatever()函数包装在代码周围,并且您then是setInterval 尝试这个的一部分
var previous = null;
var current = null;
$(document).ready(() => {
function whatever() {
var what = document.getElementById('confirmRef').innerHTML;
//console.log (what);
if (what == 'true' ) {
console.log ("call button should activate");
//console.log (what);
} else if (what == 'false' ) {
console.log ("false confirmation");
} else {
console.log ("confirm says something else!");
}
}
setInterval(function() {
$.getJSON('thenumber.json', function(data) {
var text = `The number = ${data.thenumber}<br>
Confirmed = : ${data.confirmed}`
var pass = `${data.thenumber}`
var conf = `${data.confirmed}`
$(".mypanel").html(text);
$(".passRef").html(pass);
$(".confirmRef").html(conf);
current = JSON.stringify();
if (previous && current && previous !== current) {
console.log('refresh');
location.reload();
}
previous = current;
})
.then(() => whatever());
}, 2000);
});
添加回答
举报