Possible Duplicate:
jQuery AJAX: return value on success
I am trying to load a song list from the YouTube data API and have been successful until I broke it out into it's own function.
The problem is with my local variable's value vaporizing when I return it back to the calling function. Basically, when I try to use it, it is an empty array when it has values in it. Does anybody know what might be happening?
function LoadSongList(feed){
songList = new Array();
$.getJSON(feed, function(data){
if (data['feed']) {
$.each(data['feed']['entry'], function(i, entry){
songList.push({
videoID: entry.media$group.yt$videoid.$t,
title: entry.title.$t,
tumbnailUrl: entry.media$group.media$thumbnail[0].url,
author: entry.author[0].name.$t
});
});
}
});
return songList;
}