title: Ensure jquery and FB JS SDK are both initialized
body: <p>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.</p>
  
  <p>FB.ui is called in the following manner.</p>
  
  <pre><code>        fbEnsureInit(function(){
                  FB.ui({ method: 'stream.publish', other params}, function(response){ if(response &amp;&amp; response.post_id){bi_published();}else{bi_not_published();}});                    
          });
  </code></pre>
  
  <p>technique explained here: <a href="https://stackoverflow.com/questions/3548493/how-to-detect-when-facebooks-fb-init-is-complete">How to detect when facebook&#39;s FB.init is complete</a></p>
  
  <p>What should be done in such a scenario? </p>