MCPcopy Create free account
hub / github.com/JsAaron/jQuery / done

Function done

2.0.3/Ajax.js:788–898  ·  view source on GitHub ↗
(status, nativeStatusText, responses, headers)

Source from the content-addressed store, hash-verified

786 // 清除本次请求用到的变量、解析状态码&状态描述、执行异步回调函数队列、执行complete队列、触发全局Ajax事件
787 // status: -1 没有找到请求分发器
788 function done(status, nativeStatusText, responses, headers) {
789 var isSuccess, success, error, response, modified,
790 statusText = nativeStatusText;
791
792 // Called once
793 if (state === 2) {
794 return;
795 }
796
797 // State is "done" now
798 state = 2;
799
800 // Clear timeout if it exists
801 if (timeoutTimer) {
802 clearTimeout(timeoutTimer);
803 }
804
805 // Dereference transport for early garbage collection
806 // (no matter how long the jqXHR object will be used)
807 transport = undefined;
808
809 // Cache response headers
810 responseHeadersString = headers || "";
811
812 // Set readyState
813 jqXHR.readyState = status > 0 ? 4 : 0;
814
815 // Determine if successful
816 isSuccess = status >= 200 && status < 300 || status === 304;
817
818 // Get response data
819 // 得到ajax返回的数据
820 if (responses) {
821 response = ajaxHandleResponses(s, jqXHR, responses);
822 }
823
824 // Convert no matter what (that way responseXXX fields are always set)
825 response = ajaxConvert(s, response, jqXHR, isSuccess);
826
827 // If successful, handle type chaining
828 if (isSuccess) {
829
830 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
831 if (s.ifModified) {
832 modified = jqXHR.getResponseHeader("Last-Modified");
833 if (modified) {
834 jQuery.lastModified[cacheURL] = modified;
835 }
836 modified = jqXHR.getResponseHeader("etag");
837 if (modified) {
838 jQuery.etag[cacheURL] = modified;
839 }
840 }
841
842 // if no content
843 if (status === 204 || s.type === "HEAD") {
844 statusText = "nocontent";
845

Callers 1

Ajax.jsFile · 0.70

Calls 2

ajaxHandleResponsesFunction · 0.70
ajaxConvertFunction · 0.70

Tested by

no test coverage detected