Using jQuery, I'm sending an AJAX request that will send back JSON data with HTML code. The html code will then be appended to the document's body. Here is what I'm doing:
$.get('get.php', { req: 'video_html' }, function (data) {
if (data.responsetype === "SUCCESS") {
$(document.body).append(data.video_html);
}
});
The video_html code is as following:
<video id="newVideo" src="http://.... .mp4" preload="yes">
Your browser does not support video playing.
</video>
The video is added to the document body successfully, the URL (src attribute) is also linked properly to the video but it shows a white screen instead. Anyone knows why?
I added a timeout and it worked:
$.get('get.php', { req: 'video_html' }, function (data) {
setTimeout(function(){
if (data.responsetype === "SUCCESS") {
$(document.body).append(data.video_html);
}
}, 1000);
});