1

Here is my javascript. It was working well prior to conducting a Git Pull from my partner. On a click the hint loads with fancy box. The load does not work now.

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);
                }
            });
        });
    });
},

}

2 Answers 2

2

From the error message, it sounds like your partner's code either has an infinatly looping recursive call somewhere or is calling too many functions deep.

Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

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

I think the problem might be here -- but it could be in code you don't show:

               Game.loadLevel(levelNum+1);

This will recurse but there is no way to stop it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.