Using fb.api calls with deferred jquery

I just can't plunge into deferred objects

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()));

In my opinion, .done should only work after the request is complete, and the callback sets the object as allowed, however the warning window launches a false message until the request is complete.

What am I missing?

+5
source share
1 answer

Try changing the last line of code to:

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

Thus, the use of the function is done() documented in the jQuery API

+6
source

All Articles