MCPcopy Index your code
hub / github.com/JsAaron/jQuery / ajaxConvert

Function ajaxConvert

1.6.1/src/ajax.js:892–974  ·  view source on GitHub ↗
( s, response )

Source from the content-addressed store, hash-verified

890
891// Chain conversions given the request and the original response
892function ajaxConvert( s, response ) {
893
894 // Apply the dataFilter if provided
895 if ( s.dataFilter ) {
896 response = s.dataFilter( response, s.dataType );
897 }
898
899 var dataTypes = s.dataTypes,
900 converters = {},
901 i,
902 key,
903 length = dataTypes.length,
904 tmp,
905 // Current and previous dataTypes
906 current = dataTypes[ 0 ],
907 prev,
908 // Conversion expression
909 conversion,
910 // Conversion function
911 conv,
912 // Conversion functions (transitive conversion)
913 conv1,
914 conv2;
915
916 // For each dataType in the chain
917 for( i = 1; i < length; i++ ) {
918
919 // Create converters map
920 // with lowercased keys
921 if ( i === 1 ) {
922 for( key in s.converters ) {
923 if( typeof key === "string" ) {
924 converters[ key.toLowerCase() ] = s.converters[ key ];
925 }
926 }
927 }
928
929 // Get the dataTypes
930 prev = current;
931 current = dataTypes[ i ];
932
933 // If current is auto dataType, update it to prev
934 if( current === "*" ) {
935 current = prev;
936 // If no auto and dataTypes are actually different
937 } else if ( prev !== "*" && prev !== current ) {
938
939 // Get the converter
940 conversion = prev + " " + current;
941 conv = converters[ conversion ] || converters[ "* " + current ];
942
943 // If there is no direct converter, search transitively
944 if ( !conv ) {
945 conv2 = undefined;
946 for( conv1 in converters ) {
947 tmp = conv1.split( " " );
948 if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
949 conv2 = converters[ tmp[1] + " " + current ];

Callers 1

doneFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected