Facebook like and share button on ajax Facebook like and share button on ajax ajax ajax

Facebook like and share button on ajax


XFBML tags are only parsed on Facebook JS-SDK initialization by default.

You should call FB.XFBML.parse() method once you add social plugin to DOM after page is rendered.

You may call it for all document or by specifying element to search XFBML elements within:

FB.XFBML.parse();// ORFB.XFBML.parse(DOM_ELEMENT_WHERE_AJAX_CONTENT_IS_PLACED);


If you are using multiple facebook share buttons and you also have multiple social media share buttons, then you can totally skip to include all related js which can only slows your page speed, instead of share button and its js, use only link to share your post,

And the best thing is using this method you do not have to do anything when you fetch html using ajax.

example of facebook share link:

https://www.facebook.com/sharer.php?u=[your-url]

You can use it as below:

<a href="https://www.facebook.com/sharer.php?u=[your-url]">Share on facebook</a>

You can also use css to make this link as facebook button look, or you can use image of facebook or svg for facebook.