- // Determines if an XMLHttpRequest was successful or not
- httpSuccess: function( xhr ) {
- try {
- // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
- return !xhr.status && location.protocol === "file:" ||
- // Opera returns 0 when status is 304
- ( xhr.status >= 200 && xhr.status < 300 ) ||
- xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
- } catch(e){}
-
- return false;
- },
-
- // Determines if an XMLHttpRequest returns NotModified
- httpNotModified: function( xhr, url ) {
- var last_modified = xhr.getResponseHeader("Last-Modified"),
- etag = xhr.getResponseHeader("Etag");
-
- if ( last_modified ) {
- jQuery.lastModified[url] = last_modified;
- }
-
- if ( etag ) {
- jQuery.etag[url] = etag;
- }
-
- // Opera returns 0 when status is 304
- return xhr.status === 304 || xhr.status === 0;
- },
-
- 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.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" ) {
-
- // If the type is "script", eval it in global context
- if ( type === "script" ) {
- jQuery.globalEval( data );
- }
-
- // Get the JavaScript object, if JSON is used.
- if ( type === "json" ) {
- if ( typeof JSON === "object" && JSON.parse ) {
- data = JSON.parse( data );
- } else {
- data = (new Function("return " + data))();
- }
- }
- }