Skip to content

Instantly share code, notes, and snippets.

@olivx
Created November 1, 2018 02:25
Show Gist options
  • Save olivx/0d4e1d103b90476a0c6ecb72bfa81d77 to your computer and use it in GitHub Desktop.
Save olivx/0d4e1d103b90476a0c6ecb72bfa81d77 to your computer and use it in GitHub Desktop.
estrutura exemplo download e upload via ajax com jquery
$.ajax({
type: 'POST',
url: "/",
data: {},
beforeSend: function(XMLHttpRequest)
{
//Upload progress
XMLHttpRequest.upload.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
//Do something with upload progress
}
}, false);
//Download progress
XMLHttpRequest.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
//Do something with download progress
}
}, false);
},
success: function(data){
//Do something success-ish
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment