我无法理解延迟对象
dfd = new $.Deferred();
FB.api('/me/posts?fields=id,story&access_token='+accessToken,function(response){
dfd.resolve();
//Do something with the result
});
dfd.done(alert(dfd.isDeferred()));
根据我的理解,.done
只应在请求完成后触发,并且回调将对象设置为已解析,但警报框在请求完成之前触发为假。
我错过了什么?
答案 0 :(得分:6)
尝试将最后一行代码更改为:
dfd.done(function(){ alert(dfd.isDeferred()); });
这是done()
函数的使用方式documented in the jQuery API