title: Facebook xfbml Like Button not working correctly
body: <p>I have a news section on my site that is ajax driven.  I'm trying to implement the xfbml version of the Facebook Like button and have run into a few problems.</p>
  
  <p>When clicking on 'Like' on a news item for the first time, none of the og tags are pulled in, so all you get is a comments box.
  Strangly, if I then view another news item and go back to the first news item, the like button works correctly and all og data is pulled correctly.  It seems like some sort of caching issue?</p>
  
  <p>I've also had an issue with the floating popup box disappearing after clicking on like, before having chance to enter a comment.  Its there for a fraction of a second.  If I then unlike the news item and relike it, the floating popup box does eventually stay put, but it can take several attempts.</p>
  
  <p>Here is a sample of the header</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en-GB" lang="en-GB"&gt;
  &lt;head&gt;
  &lt;meta property="og:title" content="She's in fashion"/&gt;
  &lt;meta property="og:type" content="article"/&gt;
  &lt;meta property="og:url" content="http://www.kirkleescollege.ac.uk/news/1103"/&gt;
  &lt;meta property="og:image" content="http://www.kirkleescollege.ac.uk/photo/news/1103/full"/&gt;
  &lt;meta property="og:site_name" content="Kirklees College"/&gt;
  &lt;meta property="og:description" content="This year Rebekah Crowther will take the first steps towards her dream career in fashion retail thanks to a new course at Kirklees College."/&gt;
  &lt;title&gt;Kirklees College News - She's in fashion&lt;/title&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt;
  </code></pre>
  
  <p>And this is the body code, currently on the testing server, not the live server.</p>
  
  <pre><code>&lt;div id="fb-root"&gt;&lt;/div&gt;
  &lt;script&gt;
  $(document).ajaxComplete(function(){
      try{
          FB.XFBML.parse(); 
      }catch(ex){
      }});
  
  (function(d){
    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js#appId=APPID&amp;xfbml=1";
    d.getElementsByTagName('head')[0].appendChild(js);
  }(document));
  
  
  
  &lt;/script&gt;
  
  &lt;div id="fb-root"&gt;&lt;/div&gt;
  &lt;script&gt;(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js#appId=APPID&amp;xfbml=1";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));&lt;/script&gt;
  
  &lt;div class="fb-like" data-href="http://www.kirkleescollege.ac.uk/news/&lt;?php echo $id; ?&gt;" data-send="true" data-layout="button_count" data-width="450" data-show-faces="false"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>A coulpe of things to mention about the above code, the live code has my app ID set but I wasn't sure if this was sensitive information so I've removed it here.  I'm assuming both app id's should be the same?<br>
  The FB.XFBML.parse() code came from Stackoverflow. It allows the like button to load on an ajax-driven page.<br>
  What I can't understand is why its intermittent.  You would think If something with wrong it would still be consistent.  </p>
  
  <p>Hope someone can help as this is driving me crazy!</p>