javascript - jQuery animation, fire a function every other second? -


im trying make upload script jquery , loading bar aswell.

i got field multiple upload possibility. every file gets 2 second on loading bar.

so count time have this:

var length = array.length;  var time = length*2;  var totaltime = time*1000; // count totaltime, not milliseconds. 

my question is, if upload several files, 3 files. have 6 seconds in loading bar, there way make function fire every 2 seconds? have outside animation setinterval? if how stop setinterval? or possible inside animation?

$(".filesupload").on("change", function() {    var files = $(".filesupload").prop("files");    var names = $.map(files, function(val) {      return val.name;    });    totalfiles = names.length;    $("#uploadbar").modal('show');    });  $("#uploadbar").on("shown.bs.modal", function() {    var time = totalfiles * 2;    var totaltime = time * 1000; // seconds, not milliseconds.    $(".progress-bar-success").animate({      width: "+=100%"    }, totaltime);  });
<!-- modal -->  <div class="modal" id="uploadbar">    <div class="modal-dialog" role="document">      <div class="modal-content">        <div class="modal-body">          <div class="progress">            <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>          </div>        </div>      </div>    </div>  </div>  <form method="post" enctype="multipart/form-data">    <input type="file" name="filesupload[]" class="filesupload" multiple="">  </form>


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -