运行下面的代码,页面加载dayofweek和hourofday函数.但是在浏览器(Chrome)冻结并且给出错误之后不久:net :: ERR_INSUFFICIENT_RESOURCES并且引用了jQuery库和我的hourofday.js脚本.
几分钟后,它开始像疯了一样得到错误并冻结.我甚至无法重新加载页面.
function dayofweek(){
$.ajax({
url: "dayofweek.php",
type: "POST",
dataType: "xml",
success: function (xml){
var day = $(xml).find('day').first().text();
$("#dayofweek").html(day);
},
error: function (xhr, status) {
},
complete: function (xhr, status) {
}
});
}
function hourofday(){
$.ajax({
url: "hourofday.php",
type: "POST",
dataType: "xml",
success: function (xml){
var response = $(xml).find('response').first().text();
$("#hourofday").html(response);
},
error: function (xhr, status) {
},
complete: function (xhr, status) {
}
});
setInterval(dayofweek, 6000);
setInterval(hourofday, 6000);
}
Run Code Online (Sandbox Code Playgroud)