Possible Duplicate:
How to return AJAX response Text?
I'm trying to get the following code to work. I know there's something I'm not doing right in the variable scope within the function, but I can't figure out what (I'm mainly a designer, I'm quite happy I finally managed to understand a bit what JSON is about). Could anyone nudge me into the right direction? Thanks :)
var list = new Array();
//Twitter
function twitter(photos){
    $.each(photos.results, function(index, photo){
        if (photo.entities.media){
            list.push(photo.entities.media[0].media_url);
            console.log(list); // working here, returns array
        }
    });     
}
var url = "https://search.twitter.com/search.json?callback=?&q=%23pikachu&include_entities=true&count=50";
$.getJSON(url, twitter);
console.log(list); //not working here, returns []
 
     
     
    