I just finished a small website 100% based on ajax.But i have a problem in updating the links of the facebook Like buttons.
I used simply the facebook generated code and i included the graph meta tags. when the users presses a button it loads a new youtube video, i update the meta tag
<meta property="og:url" content="http://www.mySite.com/"/>
using jQuery this way :
$("meta[property=og:url]").attr("content", nUrl);
nUrl is the new page url that contains the new randomly selected video.
When i hit “Like” it simply grab hit “Like” it simply grab the original og:url meta tag content and now the new on set by ajax.
How to update with javascript the like button url ? What is wrong in what i did ?
Thank you
So here’s what i did to solve my problem for other people who have the same:
Add this to your site :
This will add the fbml to your site. Then use the FBML version of the like button (or comment system, or whatever), for like i used this :
Now to have a new facebook like button each time the user make an Ajax action, just add this jquery code to where ever you handle this action in your client-side code:
You basically just replace the where your button is with a new one.
nUrl is the new link you want your new button to point to.
You don’t need a real new URL just add a parameter to the url so that your ajax knows what to display when he finds the parameter.
That’s all.