var links = [];
function getFeed() {
$.getJSON("http://www.reddit.com/.json?jsonp=?", function (data) {
$.each(data.data.children, function (i, item) {
var url = item.data.url;
links.push(url);
});
alert("Inside request: " + links.length);
});
}
getFeed();
alert("Outside request: " + links.length);
Result:
Outside request: 0
Inside request: 25
Since the request seems to be asynchronous, how can I revise my code to use the data from the requests synchronously?
I apologize if I'm missing something obvious here...