Javascript: is there a better way to execute a function after x amount of async database/ajax calls
using Backbone.js we have an application, in which on a certain occasion we need to send an ajax post to a clients webservice. however, the content to be posted, is dynamic, and is decided by a certain array. for each item in the array we need to go fetch a piece of data. after assembling the data that aggregated object needs to be sent. as of now, i have a synchronous approach, though i feel that this is not the best way. var arrParams = [{id: 1, processed: false},{id: 7, processed: false},{id: 4, processed: false}]; function callback(data) { $.post()... // jquery ajax to post the data... }