2013-02-20 102 views
1

这是我的javascript。在我的合作伙伴进行Git Pull之前,它工作良好。单击提示加载花哨的框。负载现在不起作用。Jquery:Uncaught RangeError:超过最大调用堆栈大小

Game = { 

loadLevel: function(levelNum) { 
    $("#level").load("/level/" + levelNum + "/", function() { 

     // disable all hints except the first 
     $("#level .hint:not(:first)").prop('disabled', true); 

     // clicking a hint displays the hint 
     $("#level .hint").each(function(index, el) { 
      $(el).fancybox({ 
       href : $(el).attr("data-url"), 
       type : 'ajax', 
      }); 
     }); 

     // enable next hint when clicking on a hint 
     $("#level .hint").on("click", function() { 
      $(this).next().prop('disabled', false); 
     }); 

     // if answer is correct load next level 
     $("#answer").on("click", function() { 
      $.get("/answer/" + levelNum + "/", { 
       guess : $('.guess').val() 
      }, function(answer) { 
       console.log(answer); 
       if (answer) { 
        Game.loadLevel(levelNum+1); 
       } 
      }); 
     }); 
    }); 
}, 

} 

回答

1

试试这个:

loadLevel: function(levelNum) { 
    if (levelNum > 5) return; 
    $("#level").load("/level/" + levelNum + "/", function() { 

我认为这个问题可能会在这里 - 但它可能是在代码中你不显示:

   Game.loadLevel(levelNum+1); 

这会重复,但也没办法停止它。

2

从错误信息,这听起来像你的伴侣的代码,通过具有infinatly循环递归调用某个地方或调用了过多的功能深。

相关问题