开发者

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开发者_如何学Go a .wait call and hide it on complete?


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)
            })
        }
    );
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜