views:

15

answers:

1

I am using the FB.ui method to publish something to the users wall and want to capture whether the user published or cancelled. To do this I am calling a function (say bi_published(){...}) which updates a table in the db which is being used to capture metrics. It does this by making a $.ajax call. The issue is bi_published has to be within $(function() {}); to ensure $ is initialized. but then when I call this from within the FB.ui then I get the error bi_published() is not defined. If I keep it outside then I get $ is not defined.

FB.ui is called in the following manner.

        fbEnsureInit(function(){
                FB.ui({ method: 'stream.publish', other params}, function(response){ if(response && response.post_id){bi_published();}else{bi_not_published();}});                    
        });

technique explained here: http://stackoverflow.com/questions/3548493/how-to-detect-when-facebooks-fb-init-is-complete

What should be done in such a scenario?

A: 

So I figured out how to achieve this.

I now put bi_published outside and then within that method I put $(function(){ making ajax call here})

Works fine.

So simple I kinda feel stupid.

sassyboy