I'm trying to make multiple JSON request inside a loop and save them into a variable so that I can use the variable later. So far I have this, but it returns an empty array. Any helps is much appreciated.
function multipleJSON(){
var arr=[];
var result = (function () {
for(var 0=1;i<10;i++){
.ajax({
'async': false,
'global': false,
'dataType': jsontype,
'url': 'index.php?param='+i+ '&callback=?',
'dataType': jsontype,
'success': function (data) {
arr.push(data);
}
});
}
return arr;
})();
return result;
}
// returns an empty array
my var=multipleJSON();