complete
deferred.promise(jqXHR).complete = completeDeferred.add; 这段有问题吧? //complete 应该指向deffered.always jqXHR.complete = jqXHR.always
deferred.promise(jqXHR).complete = completeDeferred.add; 这段有问题吧? //complete 应该指向deffered.always jqXHR.complete = jqXHR.always
2015-09-18
completeDeferred=jQuery.Callbacks("once memory"); deferred.promise(jqXHR).complete = completeDeferred.add; var fucTemp=function(f){}; deferred.promise(jqXHR).complete(fucTemp)=> completeDeferred.add(fucTemp);
所以,调用ajax的complete 添加回调方法时,实际上是在向completeDeferred的这个Callbacks中添加回调。
在最后,ajax得到请求内容后,会调用completeDeferred中的回调队列
completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); //callbackContext:为回调环境 => callbackContext = s.context || s //[ jqXHR, statusText ]:回调方法的参数
举报