rodrick
rodrick

Reputation: 87

Facebook JS SDK, FB.api handle other events like start, complete?

i am using the FB js sdk. I am a jquery and fb sdk beginner.

I am wondering how to handle other events when making .api or query . wait calls?

like.. show a throbber/loading gif at the start of a .wait call and hide it on complete?

Upvotes: 0

Views: 947

Answers (1)

ifaour
ifaour

Reputation: 38115

Hmmmm well, most Facebook Javascript calls have a callback functions so one way I could think of doing this would be:

$("#show-friends-albums").click(function() {
    $("#ajax-loader").show(); // Show the loader before the FB JS Call
    FB.api(
        {
            method: 'fql.query',
            query: 'SELECT aid,owner,name FROM album WHERE owner IN (SELECT uid2 FROM friend WHERE uid1 = me()) LIMIT 25'
        },
        function(resp) {
            $("#ajax-loader").hide(); // We got a response, Hide and process the data
            $.each(resp, function(k,v) {
                console.log(v.name)
            })
        }
    );
});

Upvotes: 1

Related Questions