title: Asynchronous complete condition with dropzone.js
body: <p>I have a page with three dropzones which each call a function to update an image on the site once they're complete. The problem is that if three files are being uploaded at the same time, the function does not fire until the last of the three has finished uploading. Is there a way to fire off an iteration of the function every single time a file is uploaded?</p>
  
  <p>Javascript:</p>
  
  <pre><code>var updatePreview = function(page) {
      $.ajax({
          url: 'submit.php',
          type:'GET',
          success: function(data){
              var pageSize = '',
                  source_preview = '',
                  source_preview_background = '';
  
              if ($(data).find('#file_0' + page + ' .ledger_preview').length) {
                  //If paper is ledger-size
                  source_preview = $(data).find('#file_0' + page + ' .ledger_preview'),
                  source_preview_background = source_preview.css('background-image');
                  $('#file_0' + page + ' .ledger_preview').css('background-image', source_preview_background);
              }
              else {
                  //If paper is letter-size
                  source_preview = $(data).find('#file_0' + page + ' .letter_preview'),
                  source_preview_background = source_preview.css('background-image');
                  $('#file_0' + page + ' .letter_preview').css('background-image', source_preview_background);
              }
         }
      });
  };
  
  Dropzone.autoDiscover = false;
  
  var dzOne = new Dropzone('#file-one', {
      url: 'submit.php',
      paramName: 'file_01',
      method: 'POST',
      init: function() {
          this.on('complete', function() {
              updatePreview('1');
          });
      },
      accept: function(file, done) {
          done();
      }
  });
  
  var dzTwo = new Dropzone('#file-two', {
      url: 'submit.php',
      paramName: 'file_02',
      method: 'POST',
      init: function() {
          this.on('complete', function() {
              updatePreview('2');
          });
      },
      accept: function(file, done) {
          done();
      }
  });
  
  var dzThree = new Dropzone('#file-three', {
      url: 'submit.php',
      paramName: 'file_03',
      method: 'POST',
      init: function() {
          this.on('complete', function() {
              updatePreview('3');
          });
      },
      accept: function(file, done) {
          done();
      }
  });
  </code></pre>