( status, nativeStatusText, responses, headers )
| 8096 | |
| 8097 | // Callback for when everything is done |
| 8098 | function done( status, nativeStatusText, responses, headers ) { |
| 8099 | var isSuccess, success, error, response, modified, |
| 8100 | statusText = nativeStatusText; |
| 8101 | |
| 8102 | // Called once |
| 8103 | if ( state === 2 ) { |
| 8104 | return; |
| 8105 | } |
| 8106 | |
| 8107 | // State is "done" now |
| 8108 | state = 2; |
| 8109 | |
| 8110 | // Clear timeout if it exists |
| 8111 | if ( timeoutTimer ) { |
| 8112 | clearTimeout( timeoutTimer ); |
| 8113 | } |
| 8114 | |
| 8115 | // Dereference transport for early garbage collection |
| 8116 | // (no matter how long the jqXHR object will be used) |
| 8117 | transport = undefined; |
| 8118 | |
| 8119 | // Cache response headers |
| 8120 | responseHeadersString = headers || ""; |
| 8121 | |
| 8122 | // Set readyState |
| 8123 | jqXHR.readyState = status > 0 ? 4 : 0; |
| 8124 | |
| 8125 | // Determine if successful |
| 8126 | isSuccess = status >= 200 && status < 300 || status === 304; |
| 8127 | |
| 8128 | // Get response data |
| 8129 | if ( responses ) { |
| 8130 | response = ajaxHandleResponses( s, jqXHR, responses ); |
| 8131 | } |
| 8132 | |
| 8133 | // Convert no matter what (that way responseXXX fields are always set) |
| 8134 | response = ajaxConvert( s, response, jqXHR, isSuccess ); |
| 8135 | |
| 8136 | // If successful, handle type chaining |
| 8137 | if ( isSuccess ) { |
| 8138 | |
| 8139 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 8140 | if ( s.ifModified ) { |
| 8141 | modified = jqXHR.getResponseHeader("Last-Modified"); |
| 8142 | if ( modified ) { |
| 8143 | jQuery.lastModified[ cacheURL ] = modified; |
| 8144 | } |
| 8145 | modified = jqXHR.getResponseHeader("etag"); |
| 8146 | if ( modified ) { |
| 8147 | jQuery.etag[ cacheURL ] = modified; |
| 8148 | } |
| 8149 | } |
| 8150 | |
| 8151 | // if no content |
| 8152 | if ( status === 204 || s.type === "HEAD" ) { |
| 8153 | statusText = "nocontent"; |
| 8154 | |
| 8155 | // if not modified |
no test coverage detected