2013-02-20 90 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循環遞歸調用某個地方或調用了過多的功能深。

相關問題