I have a Database where I store the ID of X videos from Facebook also, Youtube and vimeo, then I load any video via Ajax, vimeo and Youtube load perfectly but Facebook doesn't load, it only loads the html but the code that I get via ajax also contains a script wich is requiered by Facebook...
To embed a video from Facebook the code is 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="http://ift.tt/1OZHFwl echo $v->v; ?>" data-width="800">
<div class="fb-xfbml-parse-ignore">
</div>
</div>
</div>
</div>
with this code I can embed facebook videos, if I go directly to my ajax file, http://ift.tt/1C95aJj it will output that code only for facebook and that is what I get and it display the video correctly, but if I call it using ajax I only see the html but the script doesn't get executed in other words I don't see the video...
My ajax is 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 for all
context: document.body, // change #8
success: function (data) {
$("#slider").html(data);
},
error: function (xhr, status) {
alert("Ocurrio un problema!");
},
complete: function (xhr, data) {
// hide the loading img
}
}).done (function (data) {
// alert('sss'); // This is working...
$("#slider").find("script").each(function(i) {
eval($(this).text());
}); // this p*** of s*** is not working...
});
})
So the only problem I got is when the video is for Facebook... how can I solve this?... thanks
Aucun commentaire:
Enregistrer un commentaire