title: Executing a function after each-loop has completed
body: <p>Hey there,
  I'm working on a jQuery each()-loop containing an ajax-request an a setTimeout. That's giving me some issues with the program flow.</p>
  
  <pre><code>xml_queries: function (data) {
      var values = [];
  
      // ...
  
      $.each(data, function(index, value) {
  
          // ...
  
          // Start xml query
          var i = 0;
          get_data(value.value);
  
          function get_data(value) {
              $.ajax({
                  type: 'POST',
                  url: '/admin/scanner/get_music_data/' + value,
                  dataTaype: 'json',
                  success: function(response) {
                      if ( response === 'FALSE' ) {
                          // Start recursion - up to 3 Retries
                          if ( ++i &lt;= 3 ) {
                              setTimeout(function() {
                                  get_data();
                              }, 100);
                          } else {
                              // ...
                          }
                      } else {
                          values.push(response);
                      }
                  }
              });
          }
      });
      // return values;
      console.log(values);
  }
  </code></pre>
  
  <p>My problem is that the console.log() in the last line is fired immediatly (while the loop is still processing data). Isn't there any easy possibility to wait for the loop to finish? \:</p>
  
  <p>Best regards!</p>