小编Zek*_*iya的帖子

JavaScript setInterval()冻结了我的网站

我在我的Raspberry Pi3中安装了Apache以获得本地网站.我有这个JavaScript index.php,我需要每200ms刷新一次:

function Function()
{
    $.ajax({
        url : 'variable.php',
        data: {action: 'variable'},
        type: 'post',
        success: function(output){
            document.getElementById("demo").innerHTML= output;
            setInterval(Function(),200);
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

在variable.php,它只是一个命令的输出.

但是,在2分钟内,可用内存从220 000 KiB变为40 000 KiB,因此我的网站在10分钟内开始冻结,我必须关闭我的网络并重新打开它.

怎么了 ?

javascript setinterval

2
推荐指数
1
解决办法
434
查看次数

标签 统计

javascript ×1

setinterval ×1