I'm trying to make a simple function with js & jquery but I can't get this to work.
From what I understand, when I declare a variable without var it becomes global but I can pass a variable from a jquery callback to my main function.
function fetchEvents(start,end){
ret = [];
$j.getJSON("index.php?page=agenda_google_ajax&action=list&start="+start+"&end="+end,function(data){
console.log(data); // works ok
ret = data;
});
console.log(ret); // equals [] :'(
return ret;
}