Guest User

Untitled

a guest
Jul 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. // @override httpData method to support malformed JSON
  2. // some of our API's do not respect the JSON spec
  3. $.httpData = function( xhr, type, s ) {
  4. var ct = xhr.getResponseHeader("content-type") || "",
  5. xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
  6. data = xml ? xhr.responseXML : xhr.responseText;
  7.  
  8. if ( xml && data.documentElement.nodeName === "parsererror" ) {
  9. throw "parsererror";
  10. }
  11.  
  12. // Allow a pre-filtering function to sanitize the response
  13. // s is checked to keep backwards compatibility
  14. if ( s && s.dataFilter ) {
  15. data = s.dataFilter( data, type );
  16. }
  17.  
  18. // The filter can actually parse the response
  19. if ( typeof data === "string" ) {
  20. // Get the JavaScript object, if JSON is used.
  21. if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
  22. data = (new Function("return " + data))();
  23. }
  24. }
  25.  
  26. return data;
  27. };
Add Comment
Please, Sign In to add comment