( status, nativeStatusText, responses, headers )
| 9751 | |
| 9752 | // Callback for when everything is done |
| 9753 | function done( status, nativeStatusText, responses, headers ) { |
| 9754 | var isSuccess, success, error, response, modified, |
| 9755 | statusText = nativeStatusText; |
| 9756 | |
| 9757 | // Called once |
| 9758 | if ( state === 2 ) { |
| 9759 | return; |
| 9760 | } |
| 9761 | |
| 9762 | // State is "done" now |
| 9763 | state = 2; |
| 9764 | |
| 9765 | // Clear timeout if it exists |
| 9766 | if ( timeoutTimer ) { |
| 9767 | window.clearTimeout( timeoutTimer ); |
| 9768 | } |
| 9769 | |
| 9770 | // Dereference transport for early garbage collection |
| 9771 | // (no matter how long the jqXHR object will be used) |
| 9772 | transport = undefined; |
| 9773 | |
| 9774 | // Cache response headers |
| 9775 | responseHeadersString = headers || ""; |
| 9776 | |
| 9777 | // Set readyState |
| 9778 | jqXHR.readyState = status > 0 ? 4 : 0; |
| 9779 | |
| 9780 | // Determine if successful |
| 9781 | isSuccess = status >= 200 && status < 300 || status === 304; |
| 9782 | |
| 9783 | // Get response data |
| 9784 | if ( responses ) { |
| 9785 | response = ajaxHandleResponses( s, jqXHR, responses ); |
| 9786 | } |
| 9787 | |
| 9788 | // Convert no matter what (that way responseXXX fields are always set) |
| 9789 | response = ajaxConvert( s, response, jqXHR, isSuccess ); |
| 9790 | |
| 9791 | // If successful, handle type chaining |
| 9792 | if ( isSuccess ) { |
| 9793 | |
| 9794 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 9795 | if ( s.ifModified ) { |
| 9796 | modified = jqXHR.getResponseHeader( "Last-Modified" ); |
| 9797 | if ( modified ) { |
| 9798 | jQuery.lastModified[ cacheURL ] = modified; |
| 9799 | } |
| 9800 | modified = jqXHR.getResponseHeader( "etag" ); |
| 9801 | if ( modified ) { |
| 9802 | jQuery.etag[ cacheURL ] = modified; |
| 9803 | } |
| 9804 | } |
| 9805 | |
| 9806 | // if no content |
| 9807 | if ( status === 204 || s.type === "HEAD" ) { |
| 9808 | statusText = "nocontent"; |
| 9809 | |
| 9810 | // if not modified |
no test coverage detected