raising jquery deferred.then() once all deferred objects have been resolved
i have two javascript functions, save() and saveAll() , set up as below: function save(data) { return $.post('/save', data); } function saveAll(callback) { var dataArray = []; $.each(dataArray, function() { save(this); }); callback(); } i'm interested in modifying saveAll() so that it leverages jquery deferred objects, and raises the callback function once all save() operations have completed. however, i'm unsure of the exact syntax... specifically with relation to the $.each() inside of the $.when(). would it be something like this? function saveAll(callback) { var dataArray = []; $.when( $