( status, nativeStatusText, responses, headers )
| 484 | // It is defined here because jslint complains if it is declared |
| 485 | // at the end of the function (which would be more logical and readable) |
| 486 | function done( status, nativeStatusText, responses, headers ) { |
| 487 | |
| 488 | // Called once |
| 489 | if ( state === 2 ) { |
| 490 | return; |
| 491 | } |
| 492 | |
| 493 | // State is "done" now |
| 494 | state = 2; |
| 495 | |
| 496 | // Clear timeout if it exists |
| 497 | if ( timeoutTimer ) { |
| 498 | clearTimeout( timeoutTimer ); |
| 499 | } |
| 500 | |
| 501 | // Dereference transport for early garbage collection |
| 502 | // (no matter how long the jqXHR object will be used) |
| 503 | transport = undefined; |
| 504 | |
| 505 | // Cache response headers |
| 506 | responseHeadersString = headers || ""; |
| 507 | |
| 508 | // Set readyState |
| 509 | jqXHR.readyState = status > 0 ? 4 : 0; |
| 510 | |
| 511 | var isSuccess, |
| 512 | success, |
| 513 | error, |
| 514 | statusText = nativeStatusText, |
| 515 | response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, |
| 516 | lastModified, |
| 517 | etag; |
| 518 | |
| 519 | // If successful, handle type chaining |
| 520 | if ( status >= 200 && status < 300 || status === 304 ) { |
| 521 | |
| 522 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 523 | if ( s.ifModified ) { |
| 524 | |
| 525 | if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) { |
| 526 | jQuery.lastModified[ ifModifiedKey ] = lastModified; |
| 527 | } |
| 528 | if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) { |
| 529 | jQuery.etag[ ifModifiedKey ] = etag; |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | // If not modified |
| 534 | if ( status === 304 ) { |
| 535 | |
| 536 | statusText = "notmodified"; |
| 537 | isSuccess = true; |
| 538 | |
| 539 | // If we have data |
| 540 | } else { |
| 541 | |
| 542 | try { |
| 543 | success = ajaxConvert( s, response ); |
no test coverage detected