我用$.ajax
编写了jquery代码,它调用PHP函数。我还设置了 setInterval(function_name, 5000)
但当我启动页面控制台日志时显示了很多错误,其计数并没有停止增加。因此,现在我的内存力也有问题,我处于红色区域。
当我不设置间隔时,没有错误。 这是我的 Jquery 代码!
$(document).ready(function game_request() {
$.ajax({
url: 'profile.php',
type: 'post',
data: {
'gamer': 1
},
success: function(response) {
$("#gamerequests").html(response);
}
});
setInterval(game_request, 5000);
});
我的 jQuery 调用 PHP 代码 perfectl
。问题只是错误。
最佳答案
改用这个:
function game_request() {
$.post('profile.php', {
'gamer': 1
}).done(function(response) {
$("#gamerequests").html(response);
});
}
$(document).ready(function() {
setInterval(game_request, 5000);
});
关于javascript - Jquery Ajax 函数 setInterval - 控制台错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52791547/