Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // @override httpData method to support malformed JSON
- // some of our API's do not respect the JSON spec
- $.httpData = function( xhr, type, s ) {
- var ct = xhr.getResponseHeader("content-type") || "",
- xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
- data = xml ? xhr.responseXML : xhr.responseText;
- if ( xml && data.documentElement.nodeName === "parsererror" ) {
- throw "parsererror";
- }
- // Allow a pre-filtering function to sanitize the response
- // s is checked to keep backwards compatibility
- if ( s && s.dataFilter ) {
- data = s.dataFilter( data, type );
- }
- // The filter can actually parse the response
- if ( typeof data === "string" ) {
- // Get the JavaScript object, if JSON is used.
- if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
- data = (new Function("return " + data))();
- }
- }
- return data;
- };
Add Comment
Please, Sign In to add comment