Skip to content

Instantly share code, notes, and snippets.

@lgersman
Created September 17, 2012 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgersman/3737747 to your computer and use it in GitHub Desktop.
Save lgersman/3737747 to your computer and use it in GitHub Desktop.
query.upload.js usage example using local progress event handler
/*
* track file upload progress using local progress event handler.
*
* See https://github.com/lgersman/jquery.orangevolt-ampere/blob/master/public/lib/ampere/jquery.upload.js
*/
$.ajax({
processData : false,
contentType : false,
data : new FormData( myForm),
type : 'POST',
progress : function( jqXHR, progressEvent, upload) {
if( progressEvent.lengthComputable) {
var percent = Math.round( progressEvent.loaded * 100 / progressEvent.total) + '%';
if( upload) {
console.log( percent + ' uploaded');
} else {
console.log( percent + ' downloaded');
}
}
})
.done( function() {
$( '#console').append( '<span>Finished upload\n</span>');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment