If you read the FB.init documentation, there are some parameters that can be used while defining FB.init
. One of the parameter is xfbml
which-
Determines whether XFBML tags used by social plugins are parsed, and therefore whether the plugins are rendered or not. Defaults to false.
You said that in case of pure javascript the like plugin worked that's beacause you must have set xfbml
to true
. To get your jquery code to work simply define this paramter to true which is false by default-
$.getScript('//connect.facebook.net/en_US/all.js', function(){
FB.init({
appId: 'xxxx',
xfbml: true
});
and it shall work. Good luck!