【发布时间】:2019-05-24 14:20:32
【问题描述】:
我需要检查来自服务器的数据。我每 15 秒进行一次 Ajax 查询。但几个小时后,我的记忆溢出了。 我在 Opera、Firefox 和 Chrome 中尝试过,到处都是特别的结果
setTimeout(function timer() {
Check();
setTimeout(timer, 10000);
}, 10000);
function Check() {
$.ajax({
url: 'https://example/server/NEWS.php',
type: "POST",
catch: false,
success: (data) => {
CheckNews(data);
}
});
}
function CheckNews(data) {
if (data == 'Try again') document.location.reload();
data = JSON.parse(data);
data.forEach(function (item, i, arr) {
switch (item[0]) {
case "Del": //Delete
console.log('Del);
break;
case 'Add': //Add
console.log('Add ');
break;
case 'NewM':
break;
default:
}
});
data = null;
}
【问题讨论】:
-
这个假设得到了内存分析器分析的证实,显示的脚本被确定为原因?
标签: javascript ajax memory