Skip to content

Instantly share code, notes, and snippets.

@nitriques
Forked from db/jquery.ajax.progress.js
Last active December 23, 2015 04:58
Show Gist options
  • Save nitriques/6583457 to your computer and use it in GitHub Desktop.
Save nitriques/6583457 to your computer and use it in GitHub Desktop.
// Forked: https://gist.github.com/nitriques/6583457
(function addXhrProgressEvent() {
var originalXhr = $.ajaxSettings.xhr;
$.ajaxSetup({
progress: $.noop,
upload: $.noop,
xhr: function () {
var self = this;
var req = originalXhr();
if (req) {
if ($.isFunction(req.addEventListener)) {
req.addEventListener('progress', self.progress, false);
}
if (!!req.upload && $.isFunction(req.upload.addEventListener)) {
req.upload.addEventListener('progress', self.upload, false);
}
}
return req;
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment