1

I only want one js link and one div on the html page.

Inside the js file I'm loading scripts and divs for twitter button, Google +1 and the buttons are displaying and working correctly.

The facebook like button script alerts that it's loaded, but the button doesn't display - any ideas why? It's a text/ecmascript, should this make a difference?

$.getScript("http://connect.facebook.net/en_US/all.js#appId=211332918913418&xfbml=1", function() {
    alert ("script executed");
});


$("#social-media").append('<div id="fb-root"></div><fb:like href="http://ourworldlive.tv/index.html" send="false" layout="box_count" width="55" show_faces="false" font=""></fb:like>');

If script is in head of document, button renders.

2
  • $.getScript("connect.facebook.net/en_US/…", function() { alert ("script executed"); }); Commented Jul 20, 2011 at 15:45
  • $("#social-media").append('<div id="fb-root"></div><fb:like href="ourworldlive.tv/index.html" send="false" layout="box_count" width="55" show_faces="false" font=""></fb:like>'); Commented Jul 20, 2011 at 15:48

2 Answers 2

1

On our docs we have a little snippet about how to load the JS sdk asynchronously.

https://developers.facebook.com/docs/reference/javascript/

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: 'your app id', status: true, cookie: true,
             xfbml: 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);
  }());
</script>
Sign up to request clarification or add additional context in comments.

Comments

0

Do you have and the FB:like button so it can actually create it? Those things need to be on the page as well

1 Comment

I append a div with that information. So if I put the js in the head of the html, and still append the div for the actual button, button shows. It's only if I'm using getScript that it's now showing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.