开发者

How can I update the content of Facebook comments during AJAX-navigation

I want to put a Facebook Comments box on a page where the navigation is AJAX based. How can I trigger the Facebook Comments box to reflect the new AJAX loaded page?

Example: User visits example.com?page=1, load comments for example开发者_如何学JAVA.com?page=1. User clicks a link which updates the page to reflect the content of page=2, load comments for page=2.


In the click handler for loading ajax pages, you can replace the facebook comments code with the code for the new pages

<fb:comments href="example.com" num_posts="2" width="500"></fb:comments>    

Replace example.com with the URL of the page fetched. Also, this goes in the header:

<script src="http://connect.facebook.net/en_US/all.js#appId=188677664483920&amp;xfbml=1"></script>

Another thing: You will need to instruct the facebook API to parse all the xfbml tags again in the click handler after adding the new code by calling FB.XFBML.parse();

If this is not clear enough, let me know and I will post a complete example code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜