Sunday, December 9, 2012

Facebook JavaScript SDK: run something after all the queries are returned

First of all, you probably want to use a more efficient fql query, such as

SELECT name, sex, uid  FROM user  WHERE uid in (   SELECT uid2    FROM friend    WHERE uid1 = me() ) 

Simply pass this to graph.facebook.com/fql?q=SELECT%20%name....

Then, move the alert into the response handler, after you have completed summing up the numbers.

FB.api('/fql',    {q: "SELECT name, sex, uid FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me())"},    function (response) {     if (response.data) {         var genderCount = {             male: 0,             female: 0,             unknown: 0         };         response.data.forEach(function (row) {             genderCount[row.sex || 'unknown']++;         });         alert(JSON.stringify(genderCount));     } }); 

Source: http://facebook.stackoverflow.com/questions/13783565/facebook-javascript-sdk-run-something-after-all-the-queries-are-returned

c. difficile carmelo anthony nurse jackie nurse jackie peeps nhl playoffs masters

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.