( status, nativeStatusText, responses, headers )
| 9189 | |
| 9190 | // Callback for when everything is done |
| 9191 | function done( status, nativeStatusText, responses, headers ) { |
| 9192 | var isSuccess, success, error, response, modified, |
| 9193 | statusText = nativeStatusText; |
| 9194 | |
| 9195 | // Called once |
| 9196 | if ( state === 2 ) { |
| 9197 | return; |
| 9198 | } |
| 9199 | |
| 9200 | // State is "done" now |
| 9201 | state = 2; |
| 9202 | |
| 9203 | // Clear timeout if it exists |
| 9204 | if ( timeoutTimer ) { |
| 9205 | clearTimeout( timeoutTimer ); |
| 9206 | } |
| 9207 | |
| 9208 | // Dereference transport for early garbage collection |
| 9209 | // (no matter how long the jqXHR object will be used) |
| 9210 | transport = undefined; |
| 9211 | |
| 9212 | // Cache response headers |
| 9213 | responseHeadersString = headers || ""; |
| 9214 | |
| 9215 | // Set readyState |
| 9216 | jqXHR.readyState = status > 0 ? 4 : 0; |
| 9217 | |
| 9218 | // Determine if successful |
| 9219 | isSuccess = status >= 200 && status < 300 || status === 304; |
| 9220 | |
| 9221 | // Get response data |
| 9222 | if ( responses ) { |
| 9223 | response = ajaxHandleResponses( s, jqXHR, responses ); |
| 9224 | } |
| 9225 | |
| 9226 | // Convert no matter what (that way responseXXX fields are always set) |
| 9227 | response = ajaxConvert( s, response, jqXHR, isSuccess ); |
| 9228 | |
| 9229 | // If successful, handle type chaining |
| 9230 | if ( isSuccess ) { |
| 9231 | |
| 9232 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 9233 | if ( s.ifModified ) { |
| 9234 | modified = jqXHR.getResponseHeader("Last-Modified"); |
| 9235 | if ( modified ) { |
| 9236 | jQuery.lastModified[ cacheURL ] = modified; |
| 9237 | } |
| 9238 | modified = jqXHR.getResponseHeader("etag"); |
| 9239 | if ( modified ) { |
| 9240 | jQuery.etag[ cacheURL ] = modified; |
| 9241 | } |
| 9242 | } |
| 9243 | |
| 9244 | // if no content |
| 9245 | if ( status === 204 || s.type === "HEAD" ) { |
| 9246 | statusText = "nocontent"; |
| 9247 | |
| 9248 | // if not modified |
no test coverage detected