Change Facebook url as button using Ajax

I am wondering if it is possible to change the action of the Facebook button as an Ajax event.

What I'm trying to do: I show the article when the page was loaded. At the end of the article, I have a button that loads the next article through Ajax. Additionally, I have the following Facebook button:

<fb:like href="http://www.myurl.com" layout="standard" show-faces="true" action="like"  id="fblike" />

When I download the next article, I put the new article URL in the “href” attribute using Javascript (which works fine), but when I click on a similar button, the article’s original URL will be posted to facebook, not the new one.

Any ideas?

Many thanks.

+3
source share
2 answers

iFrame XFBML:

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fexample.com%2Fpage%2Fto%2Flike&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

. :

http://developers.facebook.com/docs/reference/plugins/like

+1

iframe, . , , , DOM; , "" :

FB.XFBML.parse();

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

+6

Source: https://habr.com/ru/post/1774678/


All Articles