title: dojo.deferred and for loop
body: <p>I have an array of values that get passed to a function. The function loops over the array and uses the values in another method. </p>
  
  <p>This works fine for the first value in the array, then all other item' I get an error: "This deferred has already been resolved".</p>
  
  <p>I would like to end up with an array of responses, it currently stops after 1 response? </p>
  
  <p>Any help? 
  thanks!</p>
  
  <pre><code>function showQueryResults(searchResults){
      function getFacIds(arr){
          var def = new dojo.Deferred();
          for (var i = 0, iLen = arr.features.length; i &lt; iLen; i++) {
              findParams.searchText = searchResults.features[i].attributes.ID;
              findTask.execute(findParams, function(response){
                  def.callback(response);
              });
          };
          return def;
      };              
      getFacIds(searchResults).then(function(result){
          console.log(result);
      });
  }
  </code></pre>