Is there a limit on how many times FBML.XFBML.parse () can be called on the page?

I have the following code to dynamically load an XFBML fragment into a Facebook IFRAME application.

HTML:

<div id="fragment" style="display:none">
<fb:serverfbml id="fragmentfbml">
</fb:serverfbml>

JQuery Code:

<script type="text/javascript">
function loadFragment()
{
    jQuery.ajax(
    { 
        url: "xfbml_fragment.php", // contains the 
        type: "POST",
        dataType: "html",
        cache: "false",
        success: function (data)
        {
            jQuery("#fragmentfbml").html(data);
            FB.XFBML.parse();
            jQuery("#fragment").css("display","block");
        }
    });
}
</script>

The jQuery AJAX call works every time, but the FB.XFBML.parse () call only works once. I added a callback to FB.XFBML.parse () using console.log () (see below) and confirmed that it only executed the first time it called.

FB.XFBML.parse(
   document.getElementbyId("fragment"),
   function( { console.log("parse called"); } )
);

Is this the famous behavior of FB.XFBML.parse () (of course, this is not mentioned in the FB Javascript SDK docs ) or am I just doing something wrong here?

+3
source share
4 answers

FB.XFBML.parse() :

function createFbmlNode() {
   var like = document.createElement("fb:like");
   like.setAttribute('href', 'URL_TO_LIKE');
   like.setAttribute('send', false);
   like.setAttribute('width', 450);
   like.setAttribute('show_faces', false);

   document.getElementById('response').appendChild(like);

   FB.XFBML.parse(); 
}

Node :

<span id="response" style="display: block;"></span>

iFrame parse.

+2

, js, . parse , JS .

0

FBML . 1 2012 FBML , FBML .

fb: serverFbml FBML

0

, FB.XFBML.parse() . .. , Facebook . .

-2

Source: https://habr.com/ru/post/1765866/


All Articles