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
Post a Comment