Facebook Like按钮在AJAX加载后刷新 [英] Facebook Like Button refresh after AJAX-Load

查看:116
本文介绍了Facebook Like按钮在AJAX加载后刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须实现一个Facebook-Likebutton,其中url是从ajax请求中获取的,这意味着我在页面加载后设置了href-attribute。不幸的是,在这个时候,url已经设置好了,所以当喜欢的时候,它将需要实际的页面url作为url ...
有没有办法刷新likebutton?

I have to implement a Facebook-Likebutton where the url is taken from an ajax request... that means i set the "href"-attribute after page-load. unfortunately, at this time the url is already set, so when liking it, it will take the actual page-url as url... is there a way to refresh the likebutton?

推荐答案

如果你使用jQuery,那么这个问题有一个非常简单和光滑的解决方案:

If you’re using jQuery, there’s a really easy and slick solution to this problem:

$(document).ajaxComplete(function(){
    try{
        FB.XFBML.parse(); 
    }catch(ex){}
});

这篇关于Facebook Like按钮在AJAX加载后刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆