我无法理解延迟对象
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
应该只在请求完成并且回调将对象设置为已解析时触发,但是在请求完成之前警报框触发 false。
我错过了什么?
最佳答案
尝试将最后一行代码更改为:
dfd.done(function(){ alert(dfd.isDeferred()); });
这就是done()
函数的使用方式documented in the jQuery API
关于jquery - 使用带有 jquery deferred 的 fb.api 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8284790/