| 7706 | * Also sets the responseXXX fields on the jqXHR instance |
| 7707 | */ |
| 7708 | function ajaxConvert( s, response, jqXHR, isSuccess ) { |
| 7709 | var conv2, current, conv, tmp, prev, |
| 7710 | converters = {}, |
| 7711 | // Work with a copy of dataTypes in case we need to modify it for conversion |
| 7712 | dataTypes = s.dataTypes.slice(); |
| 7713 | |
| 7714 | // Create converters map with lowercased keys |
| 7715 | if ( dataTypes[ 1 ] ) { |
| 7716 | for ( conv in s.converters ) { |
| 7717 | converters[ conv.toLowerCase() ] = s.converters[ conv ]; |
| 7718 | } |
| 7719 | } |
| 7720 | |
| 7721 | current = dataTypes.shift(); |
| 7722 | |
| 7723 | // Convert to each sequential dataType |
| 7724 | while ( current ) { |
| 7725 | |
| 7726 | if ( s.responseFields[ current ] ) { |
| 7727 | jqXHR[ s.responseFields[ current ] ] = response; |
| 7728 | } |
| 7729 | |
| 7730 | // Apply the dataFilter if provided |
| 7731 | if ( !prev && isSuccess && s.dataFilter ) { |
| 7732 | response = s.dataFilter( response, s.dataType ); |
| 7733 | } |
| 7734 | |
| 7735 | prev = current; |
| 7736 | current = dataTypes.shift(); |
| 7737 | |
| 7738 | if ( current ) { |
| 7739 | |
| 7740 | // There's only work to do if current dataType is non-auto |
| 7741 | if ( current === "*" ) { |
| 7742 | |
| 7743 | current = prev; |
| 7744 | |
| 7745 | // Convert response if prev dataType is non-auto and differs from current |
| 7746 | } else if ( prev !== "*" && prev !== current ) { |
| 7747 | |
| 7748 | // Seek a direct converter |
| 7749 | conv = converters[ prev + " " + current ] || converters[ "* " + current ]; |
| 7750 | |
| 7751 | // If none found, seek a pair |
| 7752 | if ( !conv ) { |
| 7753 | for ( conv2 in converters ) { |
| 7754 | |
| 7755 | // If conv2 outputs current |
| 7756 | tmp = conv2.split( " " ); |
| 7757 | if ( tmp[ 1 ] === current ) { |
| 7758 | |
| 7759 | // If prev can be converted to accepted input |
| 7760 | conv = converters[ prev + " " + tmp[ 0 ] ] || |
| 7761 | converters[ "* " + tmp[ 0 ] ]; |
| 7762 | if ( conv ) { |
| 7763 | // Condense equivalence converters |
| 7764 | if ( conv === true ) { |
| 7765 | conv = converters[ conv2 ]; |