function ajaxHandleResponses( s, jqXHR, responses ) {

  var contents = s.contents,
    dataTypes = s.dataTypes,
    responseFields = s.responseFields,
    ct,
    type,
    finalDataType,
    firstDataType;

  // Fill responseXXX fields
  for( type in responseFields ) {
    if ( type in responses ) {
      jqXHR[ responseFields[type] ] = responses[ type ];
    }
  }

  // Remove auto dataType and get content-type in the process
  while( dataTypes[ 0 ] === "*" ) {
    dataTypes.shift();
    if ( ct === undefined ) {
      ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
    }
  }

  // Check if we're dealing with a known content-type
  if ( ct ) {
    for ( type in contents ) {
      if ( contents[ type ] && contents[ type ].test( ct ) ) {
        dataTypes.unshift( type );
        break;
      }
    }
  }

  // Check to see if we have a response for the expected dataType
  if ( dataTypes[ 0 ] in responses ) {
    finalDataType = dataTypes[ 0 ];
  } else {
    // Try convertible dataTypes
    for ( type in responses ) {
      if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
        finalDataType = type;
        break;
      }
      if ( !firstDataType ) {
        firstDataType = type;
      }
    }
    // Or just use first one
    finalDataType = finalDataType || firstDataType;
  }

  // If we found a dataType
  // We add the dataType to the list if needed
  // and return the corresponding response
  if ( finalDataType ) {
    if ( finalDataType !== dataTypes[ 0 ] ) {
      dataTypes.unshift( finalDataType );
    }
    return responses[ finalDataType ];
  }
}
/* Handles responses to an ajax request:
 * - sets all responseXXX fields accordingly
 * - finds the right dataType (mediates between content-type and expected dataType)
 * - returns the corresponding response
 */
Handles responses to an ajax request:
- sets all responseXXX fields accordingly
- finds the right dataType (mediates between content-type and expected dataType)
- returns the corresponding response
Handles responses to an ajax request : - sets all responseXXX fields accordingly - finds the right dataType ( mediates between content - type and expected dataType ) - returns the corresponding response
function ajaxHandleResponses( s, jqXHR, responses ) {
  var contents = s.contents,
    dataTypes = s.dataTypes,
    responseFields = s.responseFields,
    ct,
    type,
    finalDataType,
    firstDataType;
  for( type in responseFields ) {
    if ( type in responses ) {
      jqXHR[ responseFields[type] ] = responses[ type ];
    }
  }
  while( dataTypes[ 0 ] === "*" ) {
    dataTypes.shift();
    if ( ct === undefined ) {
      ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
    }
  }
  if ( ct ) {
    for ( type in contents ) {
      if ( contents[ type ] && contents[ type ].test( ct ) ) {
        dataTypes.unshift( type );
        break;
      }
    }
  }
  if ( dataTypes[ 0 ] in responses ) {
    finalDataType = dataTypes[ 0 ];
  } else {
    for ( type in responses ) {
      if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
        finalDataType = type;
        break;
      }
      if ( !firstDataType ) {
        firstDataType = type;
      }
    }
    finalDataType = finalDataType || firstDataType;
  }
  if ( finalDataType ) {
    if ( finalDataType !== dataTypes[ 0 ] ) {
      dataTypes.unshift( finalDataType );
    }
    return responses[ finalDataType ];
  }
}
function ajaxHandleResponses ( s , jqXHR , responses ) { var contents = s . contents , dataTypes = s . dataTypes , responseFields = s . responseFields , ct , type , finalDataType , firstDataType ; for ( type in responseFields ) { if ( type in responses ) { jqXHR [ responseFields [ type ] ] = responses [ type ] ; } } while ( dataTypes [ 0 ] === "*" ) { dataTypes . shift ( ) ; if ( ct === undefined ) { ct = s . mimeType || jqXHR . getResponseHeader ( "content-type" ) ; } } if ( ct ) { for ( type in contents ) { if ( contents [ type ] && contents [ type ] . test ( ct ) ) { dataTypes . unshift ( type ) ; break ; } } } if ( dataTypes [ 0 ] in responses ) { finalDataType = dataTypes [ 0 ] ; } else { for ( type in responses ) { if ( ! dataTypes [ 0 ] || s . converters [ type + " " + dataTypes [ 0 ] ] ) { finalDataType = type ; break ; } if ( ! firstDataType ) { firstDataType = type ; } } finalDataType = finalDataType || firstDataType ; } if ( finalDataType ) { if ( finalDataType !== dataTypes [ 0 ] ) { dataTypes . unshift ( finalDataType ) ; } return responses [ finalDataType ] ; } }
Handles responses to an ajax request:
 - sets all responseXXX fields accordingly
 - finds the right dataType (mediates between content-type and expected dataType)
 - returns the corresponding response
Handles responses to an ajax request : - sets all responseXXX fields accordingly - finds the right dataType ( mediates between content - type and expected dataType ) - returns the corresponding response
// Fill responseXXX fields // Remove auto dataType and get content-type in the process // Check if we're dealing with a known content-type // Check to see if we have a response for the expected dataType // Try convertible dataTypes // Or just use first one // If we found a dataType // We add the dataType to the list if needed // and return the corresponding response