// this sets up the progress bar $(document).ready(function() { $("#uploadprogressbar").progressBar(); });
// fades in the progress bar and starts polling the upload progress after 1.5seconds function beginUpload() { // uses ajax to poll the uploadprogress.php page with the id // deserializes the json string, and computes the percentage (integer) // update the jQuery progress bar // sets a timer for the next poll in 750ms $("#uploadprogressbar").fadeIn();
var i = setInterval(function() { $.getJSON("demo.php?id=" + progress_key, function(data) { if (data == null) { clearInterval(i); location.reload(true); return; }
<div class="contentblock"> <h2>Upload Form Javascript: </h2> <pre class="ln-"><code class="js"> var progress_key = '<?= $uuid ?>';
// this sets up the progress bar $(document).ready(function() { $("#uploadprogressbar").progressBar(); });
// fades in the progress bar and starts polling the upload progress after 1.5seconds function beginUpload() { // uses ajax to poll the uploadprogress.php page with the id // deserializes the json string, and computes the percentage (integer) // update the jQuery progress bar // sets a timer for the next poll in 750ms $("#uploadprogressbar").fadeIn();
var i = setInterval(function() { $.getJSON("demo.php?id=" + progress_key, function(data) { if (data == null) { clearInterval(i); location.reload(true); return; }
var percentage = Math.floor(100 * parseInt(data.bytes_uploaded) / parseInt(data.bytes_total)); $("#uploadprogressbar").progressBar(percentage); }); }, 1500); } </code></pre> </div> </div> <!-- Ok, you so need this iframe for Safari and Chrome to work, the webkit engine doesnt allow ajax calls to be made after a form begins submission --> <iframe style="display: none;" name="progressFrame"></iframe> </body> </html>
[code="javascript"]var progress_key = '4cd0f29463edb'; // this sets up the progress bar$(document).ready(function() { $("#uploadprogressbar").progressBar();}); // fades in the progres...