Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery错误-超过最大调用堆栈大小_Javascript_Jquery - Fatal编程技术网

Javascript jQuery错误-超过最大调用堆栈大小

Javascript jQuery错误-超过最大调用堆栈大小,javascript,jquery,Javascript,Jquery,我知道有很多问题是jQuery错误造成的。但是,您可能会发现,这个错误对解决问题毫无帮助。我使用jQuery1.10.2,并在版本1.3中包含了一个名为jRumble的插件 现在,此脚本会出现错误: jQuery(document).ready(function() { jQuery('.landing-bar').jrumble({ x: 1, y: 1, rotation: 0 }); var rumbleStart

我知道有很多问题是jQuery错误造成的。但是,您可能会发现,这个错误对解决问题毫无帮助。我使用jQuery1.10.2,并在版本1.3中包含了一个名为jRumble的插件

现在,此脚本会出现错误:

jQuery(document).ready(function() {
    jQuery('.landing-bar').jrumble({
        x: 1,
        y: 1,
        rotation: 0
    });

    var rumbleStart = function() {
        jQuery('.landing-bar').trigger('startRumble');
        setTimeout(rumbleStop, 200);
    };

    var rumbleStop = function() {
        jQuery('.landing-bar').trigger('stopRumble');
        setTimeout(rumbleStart, 785);
    };

    rumbleStart();
    animateScroll();
}); 

function animateScroll() {
    jQuery('.landing-bar').animate({
        width: '100%'
    }, {
        duration: 30000,
        easing: 'linear',
        complete:function() { 
            jQuery(this).css("width","0%");
        }
    });
    animateScroll();
}
我的代码有什么问题?我认为jQuery1.10的语法可能是错误的

谢谢你的帮助

animateScoll()
放入
complete
回调中。你不希望它被这样一遍又一遍地叫

function animateScroll() {
    jQuery('.landing-bar').animate({
        width: '100%'
    }, {
        duration: 30000,
        easing: 'linear',
        complete:function() { 
            jQuery(this).css("width","0%");
            animateScroll();
        }
    });

}
说明:

动画制作完成后,将调用jQuery回调
complete
。实际上,您要做的是反复调用animate函数(在上一次调用的毫秒内),并用一个永不结束的递归函数填充解释器堆栈

堆栈将如下所示:

animateScroll()
animateScroll()
animateScroll()
animateScroll()
animateScroll()
...
您需要的是:

animateScroll()
animateScroll()
complete:function()
animateScroll()
complete:function()
animateScroll()
complete:function()
animateScroll()
...

因此,在调用新步骤之前,每个步骤都会完成。

animateScroll
中会出现无限递归。。。。你为什么在
animateScroll
内部调用
animateScroll
你有小提琴吗?抛出错误时调用什么方法?使用
setTimeout(animateScroll,30000)
而不是直接调用animateScroll,或者在animate done中调用
animateScroll()
callback@ArunPJohny那一定是那样的。这是一个加载条,当它达到100%宽度时,应开始变为100%。。难道我不能这样做吗?@ArunPJohny希望能够一次又一次地开始整个“成长到100%”过程