( status, nativeStatusText, responses, headers )
| 7452 | // It is defined here because jslint complains if it is declared |
| 7453 | // at the end of the function (which would be more logical and readable) |
| 7454 | function done( status, nativeStatusText, responses, headers ) { |
| 7455 | |
| 7456 | // Called once |
| 7457 | if ( state === 2 ) { |
| 7458 | return; |
| 7459 | } |
| 7460 | |
| 7461 | // State is "done" now |
| 7462 | state = 2; |
| 7463 | |
| 7464 | // Clear timeout if it exists |
| 7465 | if ( timeoutTimer ) { |
| 7466 | clearTimeout( timeoutTimer ); |
| 7467 | } |
| 7468 | |
| 7469 | // Dereference transport for early garbage collection |
| 7470 | // (no matter how long the jqXHR object will be used) |
| 7471 | transport = undefined; |
| 7472 | |
| 7473 | // Cache response headers |
| 7474 | responseHeadersString = headers || ""; |
| 7475 | |
| 7476 | // Set readyState |
| 7477 | jqXHR.readyState = status > 0 ? 4 : 0; |
| 7478 | |
| 7479 | var isSuccess, |
| 7480 | success, |
| 7481 | error, |
| 7482 | statusText = nativeStatusText, |
| 7483 | response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, |
| 7484 | lastModified, |
| 7485 | etag; |
| 7486 | |
| 7487 | // If successful, handle type chaining |
| 7488 | if ( status >= 200 && status < 300 || status === 304 ) { |
| 7489 | |
| 7490 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 7491 | if ( s.ifModified ) { |
| 7492 | |
| 7493 | if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) { |
| 7494 | jQuery.lastModified[ ifModifiedKey ] = lastModified; |
| 7495 | } |
| 7496 | if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) { |
| 7497 | jQuery.etag[ ifModifiedKey ] = etag; |
| 7498 | } |
| 7499 | } |
| 7500 | |
| 7501 | // If not modified |
| 7502 | if ( status === 304 ) { |
| 7503 | |
| 7504 | statusText = "notmodified"; |
| 7505 | isSuccess = true; |
| 7506 | |
| 7507 | // If we have data |
| 7508 | } else { |
| 7509 | |
| 7510 | try { |
| 7511 | success = ajaxConvert( s, response ); |
no test coverage detected