我想调用一些像这样的异步函数。为什么在案例A和案例B中我失败了,但是在案例C中成功了?这些模式jquery守护呼叫有什么区别?
情况A
firstCall()// try to get esstential parameters(a defered)
.fail(function(){
//failed :call login function again wait user to input login credential(also a defered)
})
.always(function() {
//show welcome message
})
在这种情况下失效时刚开始执行时,始终只是部分执行,而无需等待。
情况B
firstCall()// try to get esstential parameters(a defered)
.fail(function(){
//failed :call login function again wait user to input login
})
.done(function() {
//show welcome message
})
在这种情况下,如果失败,部分得到执行,但做部分从未得到执行。
案例C
firstCall()// try to get esstential parameters(a defered)
.then(null,function(){
//failed :call login function again wait user to input login
})
.always(function() {
//show welcome message
})
在这种情况下,then
部分充当故障部分,始终then
结束后可以运行。
我不知道为什么会发生这种情况。有人可以进一步解释吗?谢谢
是什么'新华美通()'返回?什么版本的jQuery? – charlietfl