javascript - Prevent parallel uploads in Jquery Form plugin -


i using jquery form plugin upload files using onchange event listener on file upload input element upload file selected.

i want allow 1 file @ time uploaded , adding rest in queue uploaded once existing upload complete.

i tried making happen using variable , setting false in beforesubmit , switching true once upload complete. however, keeps turning true automatically.

here javascript code:

var allowupload = true; console.log('initial');  var options = {             beforesubmit:  beforesubmit,           uploadprogress: onprogress,         success:       aftersuccess,         resetform: true             };    $('#upload').change(function() {      console.log(allowupload);     if(allowupload)     {         console.log('onchange:' + allowupload);         $('#uploadform').ajaxsubmit(options);      }     return false;      });  function aftersuccess(data) {    allowupload = true;    console.log('aftersuccess' + allowupload); } function beforesubmit(data) {    allowupload = false;    console.log(allowupload); } 


Comments