( status, nativeStatusText, responses, headers )
| 641 | |
| 642 | // Callback for when everything is done |
| 643 | function done( status, nativeStatusText, responses, headers ) { |
| 644 | var isSuccess, success, error, response, modified, |
| 645 | statusText = nativeStatusText; |
| 646 | |
| 647 | // Called once |
| 648 | if ( state === 2 ) { |
| 649 | return; |
| 650 | } |
| 651 | |
| 652 | // State is "done" now |
| 653 | state = 2; |
| 654 | |
| 655 | // Clear timeout if it exists |
| 656 | if ( timeoutTimer ) { |
| 657 | clearTimeout( timeoutTimer ); |
| 658 | } |
| 659 | |
| 660 | // Dereference transport for early garbage collection |
| 661 | // (no matter how long the jqXHR object will be used) |
| 662 | transport = undefined; |
| 663 | |
| 664 | // Cache response headers |
| 665 | responseHeadersString = headers || ""; |
| 666 | |
| 667 | // Set readyState |
| 668 | jqXHR.readyState = status > 0 ? 4 : 0; |
| 669 | |
| 670 | // Determine if successful |
| 671 | isSuccess = status >= 200 && status < 300 || status === 304; |
| 672 | |
| 673 | // Get response data |
| 674 | if ( responses ) { |
| 675 | response = ajaxHandleResponses( s, jqXHR, responses ); |
| 676 | } |
| 677 | |
| 678 | // Convert no matter what (that way responseXXX fields are always set) |
| 679 | response = ajaxConvert( s, response, jqXHR, isSuccess ); |
| 680 | |
| 681 | // If successful, handle type chaining |
| 682 | if ( isSuccess ) { |
| 683 | |
| 684 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 685 | if ( s.ifModified ) { |
| 686 | modified = jqXHR.getResponseHeader("Last-Modified"); |
| 687 | if ( modified ) { |
| 688 | jQuery.lastModified[ cacheURL ] = modified; |
| 689 | } |
| 690 | modified = jqXHR.getResponseHeader("etag"); |
| 691 | if ( modified ) { |
| 692 | jQuery.etag[ cacheURL ] = modified; |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | // if no content |
| 697 | if ( status === 204 || s.type === "HEAD" ) { |
| 698 | statusText = "nocontent"; |
| 699 | |
| 700 | // if not modified |
no test coverage detected