FB.init has already been called

Solution 1:

From the moment you pass parameters to the js.src like #xfbml=1&appId=X, FB SDK will auto init itself and thus FB.init will try to reinit.. So in your code, you don't have to remove the FB.init function, just make sure you don't pass parameters in the code that loads asynchronously the JS SDK.

Replace this:

js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=X";

With :

js.src = "//connect.facebook.net/en_US/sdk.js";

Hope this helps.

Solution 2:

If you really need to call init more than once you can do this:

FB._initialized = false;
FB.init();

but it makes no sense to me, I have a little bit different problem, but it is also related to FB.init has already been called - this could indicate a problem message.

I have AJAX-based website where after each page load I need to render XFBML from HTML that I get from AJAX request (comments, like button and other):

 <div class="fb-comments" data-href="{REMOVED}" data-num-posts="5" data-width="760" colorscheme="dark"></div>

To do this, you can run this when you need to render XFBML:

FB.XFBML.parse();