javascript 错误:“递归过多”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14477319/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 21:43:52  来源:igfitidea点击:

Error: "Too much recursion"

javascriptjqueryhtml

提问by fatiDev

Firebug shows me the following error: too much recursion, I tried a lot to determine what causes me this error, but in vain

Firebug 向我显示以下错误:too much recursion,我尝试了很多来确定导致我出现此错误的原因,但徒劳无功

This is my JavaScript code:

这是我的 JavaScript 代码:

$(".scan").click(function(e){
    e.preventDefault();
    var docName = $("#nomPJ").val();
    $(this).attr("nomDoc",docName);
});

Another on a separated js file:

另一个在单独的 js 文件上:

$(".scan").live("click",function(event){
    alert("frame");
    var e = event.target;
    nomDoc = $(e).attr("nomDoc");
    idDoc = $(e).attr("idDoc");
    alert("id"+idDoc);
    $("#title").text(nomDoc);
    $("#modal-body").empty().append('<iframe frameBorder="0"  height="90%" width="98%" style="margin-left: 5px"  src="/GRH/Scan.jsp?nomDoc=' + nomDoc + '&idDoc='+idDoc+'"></iframe>');
    $("#myModal").modal({ dynamic: true });
});

The html element:

html元素:

<a href="" class="scan" idDoc="1" nomDoc="" target="_blanck">numériser</a>

I removed to first code, but the problem still remains.

我删除了第一个代码,但问题仍然存在。

采纳答案by Tom Sarduy

Ok, sound like a bug, but I have readed the docsand there is not dynamic option, anyway, is well know that the modal bootstrap plugin has some other bugs like the multiple modal bug.

好的,听起来像一个错误,但我已经阅读了文档并且没有动态选项,无论如何,我很清楚模态引导插件还有一些其他的错误,比如多模态错误

Posible solutions:

可能的解决方案:

  1. Modify the modal.js which is not recommended
  2. Use another modal plugin. It seems like it works pretty well.
  3. Merge the two click events into one
  4. Delete the dynamic: trueoption on modal()function, set a fixed width to #myModaland overflow:scrollusing css.
  1. 修改不推荐的modal.js
  2. 使用另一个模态插件。看起来它工作得很好。
  3. 将两个点击事件合二为一
  4. 删除功能dynamic: true上的选项modal(),将固定宽度设置为#myModaloverflow:scroll使用 css。

回答by user3276552

For those of you trying to actually troubleshoot this in some other application, firebug/fox is pretty rough; chrome will help you out a lot more.

对于那些试图在其他应用程序中实际解决此问题的人来说,firebug/fox 非常粗糙;chrome 将为您提供更多帮助。

If you're feeling your oats, or can't use chrome, this postsaved me from a ton of hassle!

如果你感觉你的燕麦,或者不能使用 chrome,这篇文章让我免于一大堆麻烦!

long story short, it goes through logging each function automatically, so

长话短说,它会自动记录每个功能,所以

function apples () {
  bananas()
}
function bananas () {
  apples()
}

becomes

变成

function apples () {
  console.log('apples');
  bananas()
}
function bananas () {
  console.log('bananas');
  apples()
}

so that you can see exactlywhich functions are wrapped up in the all-to-vague "too much recursion"

这样您就可以确切地看到哪些函数包含在完全模糊的“太多递归”中

happy troubleshooting!

故障排除愉快!