for some sick reason, my check productIDs[addIndex] = allProductIDs[lastProductFoundIndex + i]; causes my app to spin into an infinite loop:
numberOfImagesToDisplay is set to 4
if (state == "next")
{
for(var a = 0; a < numberOfImagesToDisplay; a++) {
alert("a=" + a + ", numImages=" + numberOfImagesToDisplay)
if (a > 0) { addIndex = productIDs.length + 1; }
alert("I'm in GetNextProductIDs() 1");
//var lastProductFoundIndex = $.inArray(lastProductID, allProductIDs);
//alert("I'm in GetNextProductIDs() 2");
if (lastProductIndex >= 0) {
alert("I'm in GetNextProductIDs() 3");
//productIDs[addIndex] = allProductIDs[lastProductFoundIndex + i];
}
}
}
If I take out that line, it moves on.
Update: Resolved. lastProductIndex
was not defined. So what was happening is that it would get there and the loop would end but it's weird because a callback was being called again when it should have ended. So that callback method kept calling this method and this method would end at that spot, the callback method would again be called, and so you had an endless loop.