-
- // Handle Script loading
- if ( !jsonp ) {
- var done = false;
-
- // Attach handlers for all browsers
- script.onload = script.onreadystatechange = function(){
- if ( !done && (!this.readyState ||
- this.readyState === "loaded" || this.readyState === "complete") ) {
- done = true;
- success();
- complete();
-
- // Handle memory leak in IE
- script.onload = script.onreadystatechange = null;
- if ( head && script.parentNode ) {
- head.removeChild( script );
+
+ var // Reference url
+ url = s.url,
+ // and ifModified status
+ ifModified = s.ifModified,
+
+ // Is it a success?
+ isSuccess = 0,
+ // Stored success
+ success,
+ // Stored error
+ error = statusText;
+
+ // If not timeout, force a jQuery-compliant status text
+ if ( statusText != "timeout" ) {
+ statusText = ( status >= 200 && status < 300 ) ?
+ "success" :
+ ( status === 304 ? "notmodified" : "error" );
+ }
+
+ // If successful, handle type chaining
+ if ( statusText === "success" || statusText === "notmodified" ) {
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+
+ var lastModified = jXHR.getResponseHeader("Last-Modified"),
+ etag = jXHR.getResponseHeader("Etag");
+
+ if (lastModified) {
+ jQuery_lastModified[ s.url ] = lastModified;
+ }
+ if (etag) {
+ jQuery_etag[ s.url ] = etag;
+ }
+ }
+
+ if ( s.ifModified && statusText === "notmodified" ) {
+
+ success = null;
+ isSuccess = 1;
+
+ } else {
+ // Chain data conversions and determine the final value
+ // (if an exception is thrown in the process, it'll be notified as an error)
+ try {
+
+ var i,
+ current,
+ prev,
+ checker,
+ conv1,
+ conv2,
+ oneConv,
+ convertion,
+ dataTypes = s.dataTypes,
+ dataConverters = s.dataConverters,
+ responses = {
+ "xml": "XML",
+ "text": "Text"
+ };
+
+ for( i = 0 ; i < dataTypes.length ; i++ ) {
+
+ current = dataTypes[ i ];
+
+ if ( responses[ current ] ) {
+ jXHR[ "response" + responses[ current ] ] = response;
+ responses[ current ] = 0;
+ }
+
+ if ( i ) {
+
+ prev = dataTypes[ i - 1 ];
+
+ if ( prev !== "*" && current !== "*" && prev !== current ) {
+
+ oneConv = conv1 =
+ dataConverters[ ( conversion = prev + " " + current ) ] ||
+ dataConverters[ "* " + current ];
+
+ if ( oneConv !== true ) {
+
+ if ( ! oneConv && prev !== "text" && current !== "text" ) {
+ conv1 = dataConverters[ prev + " text" ] || dataConverters[ "* text" ];
+ conv2 = dataConverters[ "text " + current ];
+ }
+
+ if ( oneConv || conv1 && conv2 ) {
+ response = oneConv ? conv1( response ) : conv2( conv1( response ) );
+ } else {
+ throw "no " + conversion;
+ }
+ }
+ }
+ } else if ( s.dataFilter ) {
+
+ response = s.dataFilter( response );
+ dataTypes = s.dataTypes;
+ }