( status, statusText, responses, headers )
| 463 | // It is defined here because jslint complains if it is declared |
| 464 | // at the end of the function (which would be more logical and readable) |
| 465 | function done( status, statusText, responses, headers ) { |
| 466 | |
| 467 | // Called once |
| 468 | if ( state === 2 ) { |
| 469 | return; |
| 470 | } |
| 471 | |
| 472 | // State is "done" now |
| 473 | state = 2; |
| 474 | |
| 475 | // Clear timeout if it exists |
| 476 | if ( timeoutTimer ) { |
| 477 | clearTimeout( timeoutTimer ); |
| 478 | } |
| 479 | |
| 480 | // Dereference transport for early garbage collection |
| 481 | // (no matter how long the jqXHR object will be used) |
| 482 | transport = undefined; |
| 483 | |
| 484 | // Cache response headers |
| 485 | responseHeadersString = headers || ""; |
| 486 | |
| 487 | // Set readyState |
| 488 | jqXHR.readyState = status ? 4 : 0; |
| 489 | |
| 490 | var isSuccess, |
| 491 | success, |
| 492 | error, |
| 493 | response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, |
| 494 | lastModified, |
| 495 | etag; |
| 496 | |
| 497 | // If successful, handle type chaining |
| 498 | if ( status >= 200 && status < 300 || status === 304 ) { |
| 499 | |
| 500 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 501 | if ( s.ifModified ) { |
| 502 | |
| 503 | if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) { |
| 504 | jQuery.lastModified[ ifModifiedKey ] = lastModified; |
| 505 | } |
| 506 | if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) { |
| 507 | jQuery.etag[ ifModifiedKey ] = etag; |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | // If not modified |
| 512 | if ( status === 304 ) { |
| 513 | |
| 514 | statusText = "notmodified"; |
| 515 | isSuccess = true; |
| 516 | |
| 517 | // If we have data |
| 518 | } else { |
| 519 | |
| 520 | try { |
| 521 | success = ajaxConvert( s, response ); |
| 522 | statusText = "success"; |
no test coverage detected