I use the Facebook Javascript SDK to allow login / logout, and my problem is that when I use their call to window.fbAsyncInit to initiate an FB session, it always fires twice. I included a simplified sample code. I would be grateful for any help!
In the code below, warning â2â is triggered once, and then warning â1â is triggered twice.
<html><head> <script type="text/javascript"> ...some of my own functions, not related to Facebook... </script> </head> <body> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({ appId : '<?php echo FACEBOOK_APPID; ?>', session : <?php echo json_encode($session); ?>, status:false, cookie:true, xfbml: true }); alert("1"); FB.getLoginStatus(function(response) { if(response.session) { ...do stuff... } else { ...do other stuff...} }); }; alert("2"); (function() { var e = document.createElement('script'); e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; e.async = true; document.getElementById('fb-root').appendChild(e); }()); </script> ...page contents... </body></html>
source share