| 8730 | * Also sets the responseXXX fields on the jqXHR instance |
| 8731 | */ |
| 8732 | function ajaxConvert( s, response, jqXHR, isSuccess ) { |
| 8733 | var conv2, current, conv, tmp, prev, |
| 8734 | converters = {}, |
| 8735 | // Work with a copy of dataTypes in case we need to modify it for conversion |
| 8736 | dataTypes = s.dataTypes.slice(); |
| 8737 | |
| 8738 | // Create converters map with lowercased keys |
| 8739 | if ( dataTypes[ 1 ] ) { |
| 8740 | for ( conv in s.converters ) { |
| 8741 | converters[ conv.toLowerCase() ] = s.converters[ conv ]; |
| 8742 | } |
| 8743 | } |
| 8744 | |
| 8745 | current = dataTypes.shift(); |
| 8746 | |
| 8747 | // Convert to each sequential dataType |
| 8748 | while ( current ) { |
| 8749 | |
| 8750 | if ( s.responseFields[ current ] ) { |
| 8751 | jqXHR[ s.responseFields[ current ] ] = response; |
| 8752 | } |
| 8753 | |
| 8754 | // Apply the dataFilter if provided |
| 8755 | if ( !prev && isSuccess && s.dataFilter ) { |
| 8756 | response = s.dataFilter( response, s.dataType ); |
| 8757 | } |
| 8758 | |
| 8759 | prev = current; |
| 8760 | current = dataTypes.shift(); |
| 8761 | |
| 8762 | if ( current ) { |
| 8763 | |
| 8764 | // There's only work to do if current dataType is non-auto |
| 8765 | if ( current === "*" ) { |
| 8766 | |
| 8767 | current = prev; |
| 8768 | |
| 8769 | // Convert response if prev dataType is non-auto and differs from current |
| 8770 | } else if ( prev !== "*" && prev !== current ) { |
| 8771 | |
| 8772 | // Seek a direct converter |
| 8773 | conv = converters[ prev + " " + current ] || converters[ "* " + current ]; |
| 8774 | |
| 8775 | // If none found, seek a pair |
| 8776 | if ( !conv ) { |
| 8777 | for ( conv2 in converters ) { |
| 8778 | |
| 8779 | // If conv2 outputs current |
| 8780 | tmp = conv2.split( " " ); |
| 8781 | if ( tmp[ 1 ] === current ) { |
| 8782 | |
| 8783 | // If prev can be converted to accepted input |
| 8784 | conv = converters[ prev + " " + tmp[ 0 ] ] || |
| 8785 | converters[ "* " + tmp[ 0 ] ]; |
| 8786 | if ( conv ) { |
| 8787 | // Condense equivalence converters |
| 8788 | if ( conv === true ) { |
| 8789 | conv = converters[ conv2 ]; |