function ajaxConvert( s, response ) {

  // Apply the dataFilter if provided
  if ( s.dataFilter ) {
    response = s.dataFilter( response, s.dataType );
  }

  var dataTypes = s.dataTypes,
    converters = {},
    i,
    key,
    length = dataTypes.length,
    tmp,
    // Current and previous dataTypes
    current = dataTypes[ 0 ],
    prev,
    // Conversion expression
    conversion,
    // Conversion function
    conv,
    // Conversion functions (transitive conversion)
    conv1,
    conv2;

  // For each dataType in the chain
  for( i = 1; i < length; i++ ) {

    // Create converters map
    // with lowercased keys
    if ( i === 1 ) {
      for( key in s.converters ) {
        if( typeof key === "string" ) {
          converters[ key.toLowerCase() ] = s.converters[ key ];
        }
      }
    }

    // Get the dataTypes
    prev = current;
    current = dataTypes[ i ];

    // If current is auto dataType, update it to prev
    if( current === "*" ) {
      current = prev;
    // If no auto and dataTypes are actually different
    } else if ( prev !== "*" && prev !== current ) {

      // Get the converter
      conversion = prev + " " + current;
      conv = converters[ conversion ] || converters[ "* " + current ];

      // If there is no direct converter, search transitively
      if ( !conv ) {
        conv2 = undefined;
        for( conv1 in converters ) {
          tmp = conv1.split( " " );
          if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
            conv2 = converters[ tmp[1] + " " + current ];
            if ( conv2 ) {
              conv1 = converters[ conv1 ];
              if ( conv1 === true ) {
                conv = conv2;
              } else if ( conv2 === true ) {
                conv = conv1;
              }
              break;
            }
          }
        }
      }
      // If we found no converter, dispatch an error
      if ( !( conv || conv2 ) ) {
        jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
      }
      // If found converter is not an equivalence
      if ( conv !== true ) {
        // Convert with 1 or 2 converters accordingly
        response = conv ? conv( response ) : conv2( conv1(response) );
      }
    }
  }
  return response;
}
// Chain conversions given the request and the original response
Chain conversions given the request and the original response
Chain conversions given the request and the original response
function ajaxConvert( s, response ) {
  if ( s.dataFilter ) {
    response = s.dataFilter( response, s.dataType );
  }
  var dataTypes = s.dataTypes,
    converters = {},
    i,
    key,
    length = dataTypes.length,
    tmp,
    current = dataTypes[ 0 ],
    prev,
    conversion,
    conv,
    s (transitive conversion)
    conv1,
    conv2;
  for( i = 1; i < length; i++ ) {
    if ( i === 1 ) {
      for( key in s.converters ) {
        if( typeof key === "string" ) {
          converters[ key.toLowerCase() ] = s.converters[ key ];
        }
      }
    }
    prev = current;
    current = dataTypes[ i ];
    if( current === "*" ) {
      current = prev;
    } else if ( prev !== "*" && prev !== current ) {
      conversion = prev + " " + current;
      conv = converters[ conversion ] || converters[ "* " + current ];
      if ( !conv ) {
        conv2 = undefined;
        for( conv1 in converters ) {
          tmp = conv1.split( " " );
          if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
            conv2 = converters[ tmp[1] + " " + current ];
            if ( conv2 ) {
              conv1 = converters[ conv1 ];
              if ( conv1 === true ) {
                conv = conv2;
              } else if ( conv2 === true ) {
                conv = conv1;
              }
              break;
            }
          }
        }
      }
      if ( !( conv || conv2 ) ) {
        jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
      }
      if ( conv !== true ) {
        response = conv ? conv( response ) : conv2( conv1(response) );
      }
    }
  }
  return response;
}
function ajaxConvert ( s , response ) { if ( s . dataFilter ) { response = s . dataFilter ( response , s . dataType ) ; } var dataTypes = s . dataTypes , converters = { } , i , key , length = dataTypes . length , tmp , current = dataTypes [ 0 ] , prev , conversion , conv , conv1 , conv2 ; for ( i = 1 ; i < length ; i ++ ) { if ( i === 1 ) { for ( key in s . converters ) { if ( typeof key === "string" ) { converters [ key . toLowerCase ( ) ] = s . converters [ key ] ; } } } prev = current ; current = dataTypes [ i ] ; if ( current === "*" ) { current = prev ; } else if ( prev !== "*" && prev !== current ) { conversion = prev + " " + current ; conv = converters [ conversion ] || converters [ "* " + current ] ; if ( ! conv ) { conv2 = undefined ; for ( conv1 in converters ) { tmp = conv1 . split ( " " ) ; if ( tmp [ 0 ] === prev || tmp [ 0 ] === "*" ) { conv2 = converters [ tmp [ 1 ] + " " + current ] ; if ( conv2 ) { conv1 = converters [ conv1 ] ; if ( conv1 === true ) { conv = conv2 ; } else if ( conv2 === true ) { conv = conv1 ; } break ; } } } } if ( ! ( conv || conv2 ) ) { jQuery . error ( "No conversion from " + conversion . replace ( " " , " to " ) ) ; } if ( conv !== true ) { response = conv ? conv ( response ) : conv2 ( conv1 ( response ) ) ; } } } return response ; }
Chain conversions given the request and the original response
Chain conversions given the request and the original response
// Apply the dataFilter if provided // Current and previous dataTypes // Conversion expression // Conversion function // Conversion functions (transitive conversion) // For each dataType in the chain // Create converters map // with lowercased keys // Get the dataTypes // If current is auto dataType, update it to prev // If no auto and dataTypes are actually different // Get the converter // If there is no direct converter, search transitively // If we found no converter, dispatch an error // If found converter is not an equivalence // Convert with 1 or 2 converters accordingly