I have the following:
var items = [];
var myfunc= function ()
{
$.getJSON("a.txt", function (data1) {
for (key in data1) {
items.push(key);
}
});
return items[0] + " test";
}
with alert(myfunc()), I can't see the first element of my items Array. I declared that to be global but i get this: "undefined test" what could be the reason? Thanks