Chrome 中的 setinterval 不像 Mozilla 那样工作

setinterval in Chrome not working like Mozilla

我有一段代码在 Mozilla 中运行良好但在 Chrome 中运行不佳。

 function yoxi(){
    var xhr = new XMLHttpRequest;
    xhr.open("GET", "yoxi.php", false);
    xhr.send(null);
}

function getirus(){
    var xhr = new XMLHttpRequest;
    xhr.open("GET", "getirus.php", false);
    xhr.send(null);
    document.getElementById('onlineus').innerHTML=xhr.responseText;
}

setInterval(yoxi, 5000);
setInterval(getirus, 5000);

setinterval 无法在 Chrome 中重复使用。 可能是什么问题?

试试这个:

setInterval(function() {
    yoxi();
}, 5000);

setInterval(function() {
    getirus();
}, 5000);