I want to call multiple APIs inside a loop (ex: $.each). I can do this with async:false mode but it makes the script lag. How to achieve this in synchronized mode? Just ignoring async option makes only the last element in list to be sent to api calls.
$.each(lists, function(index, value) {
channel = lists[index].channel;
list = lists[index].list;
$.ajax({
url : 'api.php?list=' + list + '&from=' + from + '&to=' + to,
dataType : 'json',
async : false,
success : function(data) {
obj = data;
$.ajax({
url : 'api.php?list=' + list + '&from=' + from + '&to=' + to + '&action=sender',
dataType : 'json',
async : false,
success : function(data) {
obj['senders'] = data.msg;
CommonContainer.inlineClient.publish(channel, obj);
}
});
}
});
});