Render 'like' button after ajax call

前端 未结 2 1881
天命终不由人
天命终不由人 2021-01-31 10:48

there were a few question similar to mine on the stack but none that answered my question, so...

An ajax call returns the standard html code for creating the like button

2条回答
  •  执念已碎
    2021-01-31 11:21

    You have to call FB.XFBML.parse(); after the ajax call.

    Documentation: https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse/

    Edit: now I see that you're trying to load content into $('#thequestion'). .load takes a callback that runs after the request completes. You should do something like:

    $('#thequestion').load('/my/url', { my: 'params' }, function() {
        FB.XFBML.parse();
    });
    

    Documentation: http://api.jquery.com/load/

提交回复
热议问题