Just thought I’d share this in case anyone comes googling, as I could not find a satisfactory search result, but was fortunate that it was obvious enough that I realized the issue.
I had a page that has had a FB “like” button forever with this code:
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> <fb:like layout="button_count" show_faces="true" width="80" font="verdana"></fb:like>
I just finished using a bit of the new Facebook API to add some Facebook Connect functionality, including a “Login with Facebook” button in the sidebar of all pages in addition to the Facebook JavaScript SDK asynchronous loader:
<script type="text/javascript">// <![CDATA[ window.fbAsyncInit = function(){ FB.init({ appId : '...', session : ..., status : true, cookie : true, xfbml : true }); FB.Event.subscribe('auth.login', function(){ window.location.reload(); }); }; (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>
Before too much time passed, I discovered that on just some pages, one or both of these things would occur:
- Trying to click on the “Login with Facebook” button would do nothing but result in this JS console error: “FB.login() called before calling FB.init().”
- The page would just keep reloading itself.
You may have guessed just by looking at the above code what the cause of the problem is. The pre-existing “like” button code is loading the all.js script synchronously, but the Facebook Connect code is also loading the same file, but asynchronously. The fix is even more obvious: Remove the old <script> tag that is paired with the like button. Et voila, fin.
Caio
February 13, 2011 at 7:24 am
Fantastic. I was getting the same trouble and could’t find any solution. But taht worked fine.
Thanks a lot.
Rafal
March 1, 2011 at 6:13 am
Thanks a lot! That was it
leon
May 6, 2011 at 5:45 pm
thank you !!!!!!!!!!!!!
Qutaiba
June 21, 2011 at 6:38 pm
Thanks, this saved my life
Look
October 6, 2011 at 3:41 pm
Great !!!….
Saved our lives here..
Artemis Wolf
April 18, 2012 at 4:33 am
Mine just won’t let me enter Facebook. It’ll look like its gonna load but then “error please try again later” will appear. when I click ok it takes me to the Newsfeed but won’t let me post anything or click on somebody elses post.
oOLokiOo
June 4, 2012 at 4:26 am
Thank’s a lot, it works!
Steve
August 25, 2012 at 6:34 am
Thank you Sir, this problem was driving me mental!!
The addition of FB like to an existing page was the culprit in my case.
Thank god I found your post.