Skip to content

Instantly share code, notes, and snippets.

@dcherman
Created November 12, 2015 20:14
Show Gist options
  • Save dcherman/d5ca5978f11f58e5c5fb to your computer and use it in GitHub Desktop.
Save dcherman/d5ca5978f11f58e5c5fb to your computer and use it in GitHub Desktop.
$.ajaxSettings.xhr = (function() {
var xhrFactory = $.ajaxSettings.xhr();
return function() {
var xhr = xhrFactory();
var send = xhr.send;
xhr.send = function() {
var onload = xhr.onload;
xhr.onload = function() {
if ((xhr.responseType || 'text' ) !== 'text') {
xhr.responseText = undefined;
}
return onload.apply(this, arguments);
};
return send.apply(this, arguments);
};
return xhr;
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment