title: Javascript function callback for php code
body: <p>I am trying to send data from function to ajax call using callback function. </p>
  
  <p>I have function:</p>
  
  <pre><code>function CallAfterLogin(data,callback){
          FB.login(function(response) {  //---
          if (response.status === "connected")
          {
              LodingAnimate(); 
              FB.api('/me?fields=movies,email', function(mydata) {
              console.log(mydata);
                if(mydata.email == null)
                {
                   alert("You must allow us to access your email id!");
                   ResetAnimate();
                }else {
                  alert("hi");
                  callback(data); // &lt;=== Trigger the callback
              }
                }); //--
           } //if
               }); //---
  </code></pre>
  
  <p>Which I am calling on button click event:</p>
  
  <p><code>&lt;button type="button" onclick="CallAfterLogin()" ?&gt;Click Me!&lt;/button&gt;</code></p>
  
  <p>I want to send data to <code>ajaxResponse()</code> function:</p>
  
  <pre><code>function AjaxResponse()
   {
      document.CallAfterLogin(mydata, function(send) {
          var myData = 'connect=1'; 
          $.ajax({
          type: "POST",
          url: "process_facebook.php",
          data: {
                     connect: 1,
                     myd: mydata      //
                    }
                    }).done(function(result) {
                          $("#fb-root").html(result);
                       });
                 });
    } 
  </code></pre>
  
  <p>Above code works till <code>callback(data); // &lt;=== Trigger the callback</code> and then in Firebug I could not see any error or warning. It shows <code>profiler is running</code> for few seconds and then no activity. </p>
  
  <p>I think there's issue after call to <code>callback(data);</code> Can someone give me what is the issue here?
  I tried to call <code>ajaxResponse()</code> function on buttonclick event but it makes no action.</p>