( status, nativeStatusText, responses, headers )
| 5574 | |
| 5575 | // Callback for when everything is done |
| 5576 | function done( status, nativeStatusText, responses, headers ) { |
| 5577 | var isSuccess, success, error, response, modified, |
| 5578 | statusText = nativeStatusText; |
| 5579 | |
| 5580 | // Called once |
| 5581 | if ( state === 2 ) { |
| 5582 | return; |
| 5583 | } |
| 5584 | |
| 5585 | // State is "done" now |
| 5586 | state = 2; |
| 5587 | |
| 5588 | // Clear timeout if it exists |
| 5589 | if ( timeoutTimer ) { |
| 5590 | clearTimeout( timeoutTimer ); |
| 5591 | } |
| 5592 | |
| 5593 | // Dereference transport for early garbage collection |
| 5594 | // (no matter how long the jqXHR object will be used) |
| 5595 | transport = undefined; |
| 5596 | |
| 5597 | // Cache response headers |
| 5598 | responseHeadersString = headers || ""; |
| 5599 | |
| 5600 | // Set readyState |
| 5601 | jqXHR.readyState = status > 0 ? 4 : 0; |
| 5602 | |
| 5603 | // Determine if successful |
| 5604 | isSuccess = status >= 200 && status < 300 || status === 304; |
| 5605 | |
| 5606 | // Get response data |
| 5607 | if ( responses ) { |
| 5608 | response = ajaxHandleResponses( s, jqXHR, responses ); |
| 5609 | } |
| 5610 | |
| 5611 | // Convert no matter what (that way responseXXX fields are always set) |
| 5612 | response = ajaxConvert( s, response, jqXHR, isSuccess ); |
| 5613 | |
| 5614 | // If successful, handle type chaining |
| 5615 | if ( isSuccess ) { |
| 5616 | |
| 5617 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 5618 | if ( s.ifModified ) { |
| 5619 | modified = jqXHR.getResponseHeader("Last-Modified"); |
| 5620 | if ( modified ) { |
| 5621 | jQuery.lastModified[ cacheURL ] = modified; |
| 5622 | } |
| 5623 | modified = jqXHR.getResponseHeader("etag"); |
| 5624 | if ( modified ) { |
| 5625 | jQuery.etag[ cacheURL ] = modified; |
| 5626 | } |
| 5627 | } |
| 5628 | |
| 5629 | // if no content |
| 5630 | if ( status === 204 || s.type === "HEAD" ) { |
| 5631 | statusText = "nocontent"; |
| 5632 | |
| 5633 | // if not modified |
no test coverage detected