javascript - Embed Facebook video via ajax -


i have database store id of x videos facebook also, youtube , vimeo, load video via ajax, vimeo , youtube load facebook doesn't load, loads html code via ajax contains script wich requiered facebook...
embed video facebook code this:

<script>     (function(d, s, id)     {  var js, fjs = d.getelementsbytagname(s)[0];         if (d.getelementbyid(id)) return;         js = d.createelement(s);         js.id = id;         js.src = "//connect.facebook.net/en_us/sdk.js#xfbml=1&version=v2.0";         fjs.parentnode.insertbefore(js, fjs);     }(document, 'script', 'facebook-jssdk')         ); </script> <div class="hidden-xs hidden-sm visible-md visible-lg">     <div id="fbid">         <div id="fb-root"></div>         <div class="fb-post" data-href="https://www.facebook.com/video.php?v=<?php echo $v->v; ?>" data-width="800">             <div class="fb-xfbml-parse-ignore">             </div>         </div>     </div> </div> 

with code can embed facebook videos, if go directly ajax file, http://foo.com/ajax.php?i=1 output code facebook , , display video correctly, if call using ajax see html script doesn't executed in other words don't see video...
ajax this

$('.v_list li').click(function(){     var $ids = $(this).attr('id');     $.ajax({         url: "v.php",         data: {             vid: $ids         },         type: "get",         // datatype: "html", // test #7 .. working         context: document.body, // change #8         success: function (data) {             $("#slider").html(data);         },         error: function (xhr, status) {             alert("ocurrio un problema!");         },         complete: function (xhr, data) {             // hide loading img         }     }).done (function (data) {         // alert('sss'); // working...         $("#slider").find("script").each(function(i) {             eval($(this).text());         }); // p*** of s*** not working...      }); }) 

so problem got when video facebook... how can solve this?... thanks

after loading html code ajax, may need use fb.xfbml.parse:

fb.xfbml.parse(); 

source: https://developers.facebook.com/docs/reference/javascript/fb.xfbml.parse


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -