public/js/app.js
/* Handles responses to an ajax request:
 * - finds the right dataType (mediates between content-type and expected dataType)
 * - returns the corresponding response
 */
Handles responses to an ajax request:
- finds the right dataType (mediates between content-type and expected dataType)
- returns the corresponding response
Handles responses to an ajax request : - finds the right dataType ( mediates between content - type and expected dataType ) - returns the corresponding response
function ajaxHandleResponses( s, jqXHR, responses ) {
 	var ct, type, finalDataType, firstDataType,
 	contents = s.contents,
 	dataTypes = s.dataTypes;
	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 ct , type , finalDataType , firstDataType , contents = s . contents , dataTypes = s . dataTypes ; 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:
 - finds the right dataType (mediates between content-type and expected dataType)
 - returns the corresponding response
Handles responses to an ajax request : - finds the right dataType ( mediates between content - type and expected dataType ) - returns the corresponding response
// 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