When I request Twitter for all user locations, I encounter an issue where all my array objects end up with the same location - specifically the last one from the $.each loop.
It seems like I am unable to loop through all array values properly due to the each function. I have also attempted moving it outside of the each loop but encountered the same problem. Can anyone provide a solution to this? Thank you!
function retrieveUserLocations(user_ids){
$.getJSON("http://api.twitter.com/1/users/lookup.json?user_id="+user_ids+"&callback=?",
function(data){
$.each(data, function(i, item){
var location = item.location;
for(var i = 0; i < array.length; i++){
array[i].location = location;
}
});
console.log(array);
});//get.json
}//retrieveUserLocations function