Skip to content

Instantly share code, notes, and snippets.

@dotspencer
Last active June 8, 2016 06:54
Show Gist options
  • Save dotspencer/dae54e853e63f14a9924c2f4dda64a93 to your computer and use it in GitHub Desktop.
Save dotspencer/dae54e853e63f14a9924c2f4dda64a93 to your computer and use it in GitHub Desktop.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<div class="progress"></div>
<script>
console.log("hi");
$.ajax({
success: function(data){
console.log(data);
// Do stuff with the returned file
},
type: 'post',
url: 'http://spencerlarry.com',
xhr: function(){
// get the native XmlHttpRequest object
var xhr = $.ajaxSettings.xhr() ;
// set the onprogress event handler
xhr.upload.onprogress = function(evt){ console.log('progress', evt.loaded/evt.total*100) } ;
// set the onload event handler
xhr.upload.onload = function(){ console.log('DONE!') } ;
// return the customized object
return xhr ;
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment