I am trying to use AngularJS to execute multiple http POST requests and I need to create an object of successfully finished requests - something like this:
v
This will do the trick:
var params = [1, 2, 3], url, i, done = {}; for (i in params) { (function(p) { url = '/dir/'+ params[p]; $http.post(url, {"some_request": "not important"}). success(function(response) { done[params[p]] = 'successful'; }); })(i); }
Another option is closure.