If I dwell on the results of a JSON call, how do I know if I am in the first iteration?
In this example, I compiled a variable loopIndexto indicate what I am looking for, but it is not actually set anywhere.
How do you know where you are in the loop - what iteration are you on?
$.getJSON(myurl, function(data) {
$.each(data.results, function() {
if(loopIndex==0){
console.log("first iteration!");
}
});
});
source
share