I have this code:
$(document).ready(function(){
var dsg = new contract('1', '/json/dsgABI.json');
console.log(dsg.data);
});
var contract = function(contractAddress, abiFile){
var data = new Object();
$.when(abi()).then(function(abi) {
data.abi = abi;
});
function abi(){
return $.getJSON(abiFile, function(abi){
return abi;
});
}
this.data = data;
}
But when a use console.log(dsg.data.abi[0])
I get undefined
.
Can you help me write code that allows me to call the data array both inside and outside the function, and in the array there were results of the function.
P.S.: async
function will be 10 or more! And I need push results onto an array and use it when I need!