Created
November 1, 2018 02:25
-
-
Save olivx/0d4e1d103b90476a0c6ecb72bfa81d77 to your computer and use it in GitHub Desktop.
estrutura exemplo download e upload via ajax com jquery
This file contains hidden or 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
$.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