Created
September 17, 2012 14:35
-
-
Save lgersman/3737747 to your computer and use it in GitHub Desktop.
query.upload.js usage example using local progress event handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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