( status, nativeStatusText, responses, headers )
| 8162 | |
| 8163 | // Callback for when everything is done |
| 8164 | function done( status, nativeStatusText, responses, headers ) { |
| 8165 | var isSuccess, success, error, response, modified, |
| 8166 | statusText = nativeStatusText; |
| 8167 | |
| 8168 | // Called once |
| 8169 | if ( state === 2 ) { |
| 8170 | return; |
| 8171 | } |
| 8172 | |
| 8173 | // State is "done" now |
| 8174 | state = 2; |
| 8175 | |
| 8176 | // Clear timeout if it exists |
| 8177 | if ( timeoutTimer ) { |
| 8178 | clearTimeout( timeoutTimer ); |
| 8179 | } |
| 8180 | |
| 8181 | // Dereference transport for early garbage collection |
| 8182 | // (no matter how long the jqXHR object will be used) |
| 8183 | transport = undefined; |
| 8184 | |
| 8185 | // Cache response headers |
| 8186 | responseHeadersString = headers || ""; |
| 8187 | |
| 8188 | // Set readyState |
| 8189 | jqXHR.readyState = status > 0 ? 4 : 0; |
| 8190 | |
| 8191 | // Determine if successful |
| 8192 | isSuccess = status >= 200 && status < 300 || status === 304; |
| 8193 | |
| 8194 | // Get response data |
| 8195 | if ( responses ) { |
| 8196 | response = ajaxHandleResponses( s, jqXHR, responses ); |
| 8197 | } |
| 8198 | |
| 8199 | // Convert no matter what (that way responseXXX fields are always set) |
| 8200 | response = ajaxConvert( s, response, jqXHR, isSuccess ); |
| 8201 | |
| 8202 | // If successful, handle type chaining |
| 8203 | if ( isSuccess ) { |
| 8204 | |
| 8205 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 8206 | if ( s.ifModified ) { |
| 8207 | modified = jqXHR.getResponseHeader("Last-Modified"); |
| 8208 | if ( modified ) { |
| 8209 | jQuery.lastModified[ cacheURL ] = modified; |
| 8210 | } |
| 8211 | modified = jqXHR.getResponseHeader("etag"); |
| 8212 | if ( modified ) { |
| 8213 | jQuery.etag[ cacheURL ] = modified; |
| 8214 | } |
| 8215 | } |
| 8216 | |
| 8217 | // if no content |
| 8218 | if ( status === 204 || s.type === "HEAD" ) { |
| 8219 | statusText = "nocontent"; |
| 8220 | |
| 8221 | // if not modified |
no test coverage detected