Can I simply append youtube embed code with jQuery or should I use AJAX? -


i need dynamically load youtube embed video on 1 of sites , wondering if following technique, using jquery, acceptable :

var video_html = '<p class="x">x</p><iframe width="650" height="385" src="//www.youtube.com/embed/embed_url" frameborder="0" allowfullscreen></iframe>'; $('element').append(video_html); 

is there reason why should use ajax instead ?

ajax used when need call service. think ajax not needed here. can change src of iframe:

$('#iframeid').attr('src', '//www.youtube.com/new_video_url'); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -