2

Hello I have a problem with my website. I'm downloading my content via $.ajax from my php file. (echo "My downloaded content <fb:like .....";) In my content I have also facebook like buttons etc and the problem is that when I download content via Ajax all of facebook features are hidden (not working). When I had my content without ajax everything worked fine. I have my facebook api script in the bottom of my page.

here is my javascript and html code : http://jsfiddle.net/FWeUT/

and php is just echo.

4

1 回答 1

0

Facebook 仅在加载其 JS 包含后才会在页面上呈现代码。您可以在 AJAX 调用之后安全地重写 Facebook JS 包含。看到您正在使用 jQuery,请考虑以下内容:

if (typeof (FB) != 'undefined') {
    FB.init({ status: true, cookie: true, xfbml: true });
} else {
    $.getScript("http://connect.facebook.net/en_US/all.js#xfbml=1", function () {
        FB.init({ status: true, cookie: true, xfbml: true });
    });
}
于 2012-11-06T04:30:57.257 回答