$.getJSON('http://twitter.com/followers/ids.json?screen_name=/…'+ query1 + '&callback=?',
function(data) {
alert('JSON data string 1 is: '+data);
$.getJSON('http://twitter.com/followers/ids.json?screen_name=/…'+ query2 + '&callback=?',
function(data1) {
alert('JSON data string 2 is: '+data1);
f2=data1;
f1=data;
for(var i=0; i "less than" f1.length; i++)
{
for(var j=0; j "less than" f2.length; i++)
{
if (f1[i] == f2[j])
{
common[c]=f1[i];
c+=1;
}
}
}
$('#content').append(''+common.length+'');//this line is not working though.......
});
});
In this piece of the line
$('#content').append(''+common.length+'');
doesnt show the output actually it the page hangs
Any help will be appreciated.
Thank You
Don’t nest the calls. You also avoid some memory issues where javascript maintains a copy of all local variables for every anonymous function. By making the two calls separately you can also perform both calls at once instead of sequentially.
This is a better method if I understand your purpose. Plus by polling gotA and gotB you can even make a nice little “waiting for A, waiting for B” notification for users.
Edit: Added for loop fix from previous answer.