Skip to content

Instantly share code, notes, and snippets.

@oswaldoacauan
Created August 27, 2013 12:17
Show Gist options
  • Save oswaldoacauan/6352781 to your computer and use it in GitHub Desktop.
Save oswaldoacauan/6352781 to your computer and use it in GitHub Desktop.
Javascript - jQuery Ajax Progress
// 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