title: How to wait for the facebook javascript api response using javascript or jquery
body: <p>I want my my postuserWall() function to wait for the FB.api response then it return true or false.but it is not waiting for the response.
  How can i get it to wait for the response 
  here is my main function which is calling the postuserWall function the alert is showing me <code>undefined</code> </p>
  
  <pre><code>$('.vacancies_tbl').on('click', '.btn-edit-vacancy', function(e) {
          e.preventDefault();
           var $this = $(this);                   
           var chcek =  postuserWall();
           alert(chcek);
           if(check){
              window.location = $this.attr('href');
           }                                                              
  }); 
  </code></pre>
  
  <p>Here is my postuserWall function</p>
  
  <pre><code> function postuserWall(){
  
          var body = 'Usama New Post';
          FB.api('/me/feed', 'post', { message: body }, function(response) {
            if (!response || response.error) {
              console.log(response);
              alert('Error occured');
              return false;
            } else {
              alert('Post ID: ' + response.id);
              return true;
            }
          });
      }
  </code></pre>
  
  <p>it is not waiting for the response in the postuserWall function</p>