Skip to content

Instantly share code, notes, and snippets.

@monjudoh
Created March 6, 2010 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monjudoh/323526 to your computer and use it in GitHub Desktop.
Save monjudoh/323526 to your computer and use it in GitHub Desktop.
(function($){
if(typeof DOMParser === 'undefined')return;
var _httpData = $.httpData;
$.httpData = function( xhr, type, s ) {
var ct = xhr.getResponseHeader("content-type"),
xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
data = xml ? xhr.responseXML : xhr.responseText;
if(!xml || data){
return _httpData( xhr, type, s );
}
data = new DOMParser().parseFromString(xhr.responseText, "text/xml");
if (data.documentElement.tagName == 'parsererror'){
throw 'parsererror';
}
return data;
};
})
(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment