jquery - Facebook Connect Javascript error -
at top of page put this:
<script type="text/javascript" src="http://connect.facebook.net/en_us/all.js#xfbml=1"></script> then in body this:
<div id="fb-root"></div> then have later on in page:
<fb:login-button perms="publish_stream">connect facebook</fb:login-button> and in jquery document ready have this:
fb.init({ appid: '115************', cookie: true, status: true, xfbml: true }); in ff, loads fine, , when click connect facebook, works fine. in every other browser, loads fine, when click connect facebook, error:
fb.login() called before calling fb.init().
any ideas?
p.s. puttin init() script in head of document doesn't work either. gives same error.
p.p.s. moving init() <head> makes work ie , ff now, not safari or chrome.
one thing consider <div id="fb-root"></div> should last thing on page, right before closing </body> tag.
updated:
also, instead of calling fb.init() in document.ready, facebook documentation suggests , put in fbasyncinit block:
<div id="fb-root"></div> <script> window.fbasyncinit = function() { fb.init({ appid : 'your app id', status : true, // check login status cookie : true, // enable cookies allow server access session xfbml : true // parse xfbml }); }; (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>
Comments
Post a Comment