javascript - Global access to array values made from Json -


$.getjson("sluzba.json", function(result){     array = $.each(result, function(value){         return value;     });   tablemaker(array); }); 

this code, want have access array outside scope of function.

is possible?

please help...

yes, possible. can using callback method.

function myfunction(callback){     $.getjson("sluzba.json", function(result){     array = $.each(result, function(value){        return value;     });     callback(array);     tablemaker(array);     }); } myfunction(function(myarray){    console.log(myarray); }); 

Comments

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -