title: Jquery call another function after ajax in loop is done
body: <p>I have an ajax function that runs inside a loop and is dependent on the amount of items in the array. How do I run another function after the ajax call is done and outside the loop? Is it possible?</p>
  
  <p>This is the function</p>
  
  <pre><code>function downloadAll(){
      downloads = [];
      $.each(checked, function(key, value) {
          $.ajax({
              method: "POST",
              url: "&lt;?php echo site_url($this-&gt;data['controller'].'/Download/'); ?&gt;",
              data:'id='+value,
              beforeSend: function () {
                  $('.loading').show();
              },
              success: function(data){
                  downloads.push(data);
                  $('.loading').fadeOut("slow");
              },
          });
      }); 
      processZip(downloads);
  }
  </code></pre>