Created
August 27, 2013 12:17
-
-
Save oswaldoacauan/6352781 to your computer and use it in GitHub Desktop.
Javascript - jQuery Ajax Progress
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
// Live demo | |
// http://jsfiddle.net/GvdSy/ | |
$.ajax({ | |
xhr: function () { | |
var xhr = new window.XMLHttpRequest(); | |
xhr.upload.addEventListener("progress", function (evt) { | |
if (evt.lengthComputable) { | |
var percentComplete = evt.loaded / evt.total; | |
} | |
}, false); | |
xhr.addEventListener("progress", function (evt) { | |
if (evt.lengthComputable) { | |
var percentComplete = evt.loaded / evt.total; | |
} | |
}, false); | |
return xhr; | |
}, | |
type: 'POST', | |
url: "/", | |
data: data, | |
success: function (data) {} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment