0

I'm a beginner and I can't understand why at row 24, the console.log returns undefined, undefined because idGame and percentage are parameters of my function that I call in the .done() and the console.log at row 11 is working. Can someone explain to me what is wrong with my code below?

var width = 0;
var progress;
$(function(){
    $.ajax({
        type : 'get',
        dataType: 'json',
        url : 'controller/game/ajaxProgressGame.php',
    }).done(function(data){
        for(var i = 0 ; i < data.length - 1; i += 2)
        {   
            console.log(data[i],data[i+1]);
            /*var*/goProgress = setInterval(function(){
            progressBarChose(data[i],data[i+1])
            },10);
            setTimeout(function(){
                clearInterval(goProgress);
            },1100);
        }
    });
});

function progressBarChose(idGame,percentage)
{   
    console.log(idGame,percentage);
    if(width >= percentage )
    {   
        $('#progressBar'+idGame).html(Math.floor(width) + '%');     
        return false;
    } else {
        width++;
        $('#progressBar'+idGame).css('width' , width +'%' );
        $('#progressBar'+idGame).html(Math.floor(width) + '%');     
    }
}
Eby Jacob
  • 1,418
  • 1
  • 10
  • 28
Q.Kira
  • 1
  • 1

0 Answers0