Adding php code in javascript function -


i have php code want execute on button click event in function. tried in various way no luck. it's easy new not do.

<?php session_start(); $appid = '----';  $appsecret = '----'; // facebook app secret $return_url = 'dev01.dev/fb/facebook-php-sdk/examples/';  //path script folder   ?> <!doctype html> <html xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en-gb" lang="en-gb" ><head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <title>js/ajax facebook connect</title>  <script>   function ajaxresponse()  {      alert("hi");    }  function lodinganimate() //show loading image {     $("#loginbutton").hide();        ajaxresponse();     }  </script></head><body> <?php if(!isset($_session['logged_in'])) { ?>     <div id="results">    </div>     <div class="results1">    </div>     <div id="loginbutton">     <button type="button" onclick="callafterlogin()" ?>click me!</button>      </div> <?php } ?> <div id="fb-root"></div> <script type="text/javascript"> //------- window.fbasyncinit = function() { fb.init({     appid: '<?php echo $appid; ?>',     cookie: true,     xfbml: true,     channelurl: '<?php echo $return_url; ?>channel.php',     oauth: true});};  (function() {     var e = document.createelement('script');     e.async = true;     e.src = document.location.protocol +'//connect.facebook.net/en_us/all.js';     document.getelementbyid('fb-root').appendchild(e);}());  function callafterlogin(){         fb.login(function(response) {  //---         if (response.status === "connected")         {             lodinganimate();                              } //if              }); //---           }         <div id="results">            </div>        </script> </body> </html> 

if possible want execute in ajaxresponse function. code is:

if (!class_exists('facebookapiexception')) {     require_once('facebook.php' );     }         $facebook = new facebook(array(         'appid' => $appid,         'secret' => $appsecret,     ));     $fbuser = $facebook->getuser();     if ($fbuser)      {             try {              $user_interest = $facebook->api('/me/movies');echo '<pre>';             foreach ($user_interest['data'] $var)         {              $id=$var['id'];              $name=$var['name'];              echo '<br/>';              print_r($name); echo '<br/>';              print_r($id);         }         echo '</pre>';     }     catch (facebookapiexception $e) {         echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';         $user = null;     }     } 


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -