Luckily this forum exist, so of I go with posting a tricky question to the great masters... I am working on a program that loads multiple images in a page. The program does what it suppose to do, the problem is that I am getting an undefined error, and I don't have any idea what is the cause, the program is the following:
var imagesList = [['aaa','sss'], ['bbb','ttt']]; putImages(imagesList); function putImages(imagesList){ var i = 0; if ($(imagesList).length > 0){ LoadImage(i, imagesList); } } function LoadImage(i, imagesList){ var ele = imagesList[i][0], name = imagesList[i][1]; if(i < $(imagesList).length){ var curr = $('<li id="pic-'+ i +'"><div>' + name +'</div>').addClass("loading"); $(curr).appendTo(".photos"); var image = new Image(); $(image).load(function(){ $(this).appendTo("#pic-" + i); $(curr).removeClass("loading"); LoadImage(i+1, imagesList ); }).error(function(){ }).attr("src", ele); } } I tried to use the advice from this link JavaScript Multidimensional Arrays, but it is just what ever I try i keep getting this error in Firefox, the other browsers seem to be ok.
Thanks a lot in advance.
imagesList? Why are you passing it to jQuery? I'm pretty sure Firebug tells you in which line you get the error. Without knowing the structure of the array, we cannot help you.