Syntax issue here as the code works fine. I have a for loop and an inline function that must run within it (aQuery callback).
for (i=1;i <= 5;i++)
{
twitter[i] = $(this).find('twitter' + i).text();
//$('<div class="twitter[i]"></div>').html(twitter[i]).appendTo('#link_'+i);
$('.twitter[i]').html(twitter[i]).appendTo('#link_'+i);
// grab from twitter
$.getJSON('http://api.twitter.com/1/users/show.json?screen_name='+twitter[i]+'&callback=?',
function (data)
{
for (j=1;j <= 5; j++) {
twit_count[j] = data['followers_count'].toString();
twit_count[j] = add_commas(twit_count[j]);
$('#twitter_count'+j).html(twit_count[j]);
}
});
}
If i=3 I want j to be the same value within the function.
The problem is the j loop runs five times for every i loop.
Passing i as an argument
function (data, i)
doesn't work, some direction would be highly appreciated.
Thanks,