I have an array of string (id) and I need to iterate on it to make an ajax request to an api and push response in an array. The problem is that, because of asynchronous load, the return statement is made before the end of the call. Here an example:
getArrConcat: function (id) {
var arr = new Array();
var arrJoin = "";
for (var i=0; i<id.length; i++){
Model.load(id[i], {
success: function (org) {
arr.push(org.data);
}
});
}
arrJoin = arr.join('; ');
return arrJoin;
}