Skip to content

Instantly share code, notes, and snippets.

@chukitow
Created July 30, 2014 02:41
Show Gist options
  • Select an option

  • Save chukitow/90687050f71e4b6246ec to your computer and use it in GitHub Desktop.

Select an option

Save chukitow/90687050f71e4b6246ec to your computer and use it in GitHub Desktop.
$(function() {
/* variables */
var status = $('.status');
var percent = $('.percent');
var bar = $('.bar');
/* submit form with ajax request using jQuery.form plugin */
$('form').ajaxForm({
/* set data type json */
dataType:'json',
/* reset before submitting */
beforeSend: function() {
status.fadeOut();
bar.width('0%');
percent.html('0%');
},
/* progress bar call back*/
uploadProgress: function(event, position, total, percentComplete) {
var pVel = percentComplete + '%';
bar.width(pVel);
percent.html(pVel);
},
/* complete call back */
complete: function(data) {
status.html(data.responseJSON.count + ' Files uploaded!').fadeIn();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment