使用fqu.api调用jquery延迟

时间:2011-11-27 10:07:21

标签: jquery facebook facebook-graph-api

我无法理解延迟对象

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只应在请求完成后触发,并且回调将对象设置为已解析,但警报框在请求完成之前触发为假。

我错过了什么?

1 个答案:

答案 0 :(得分:6)

尝试将最后一行代码更改为:

dfd.done(function(){ alert(dfd.isDeferred()); });

这是done()函数的使用方式documented in the jQuery API