run FQL query after Facebook api initialization
I am trying to run some facebook query just after initializing the api using the following code :
window.fbAsyncInit = function() {
FB.init({...});
makeCall(); // this won't work
setTimeout(makeCall, 1000); // this will work
};
var makeCall = function() {
console.log("exe开发者_StackOverflow中文版c some query ")
var query = FB.Data.query("SELECT ...");
query.wait(function(friends) {
console.log("query result ...");
});
}
Somehow the query only get executed when I set a time out. Is there some better way of doing that rather than setting some timeout
try to move makeCall definition inside the window.fbAsyncInit = function() scope for example immediately after FB.init call.
hope this helps
精彩评论