Play youtube video when clicking on a preview image, php and javascript
<p>I originally was using this javascript to make a preview image play a youtube video on a click event:</p>

<pre><code>$(document).ready(function(){

    $("#feature_content").click(function(){
        var iframe = "&lt;iframe /&gt;";

        var url = "http://www.youtube.com/embed/SERIAL_NUMBER?autoplay=1&amp;autohide=1&amp;modestbranding=1&amp;rel=0&amp;hd=1";

        var width = 600;
        var height = 335;
        var frameborder = 0;

         $(iframe, {
            name: 'videoframe',
            id: 'videoframe',
            src: url,
            width: '600',
            height: '335',
            frameborder: 0,
            class: 'youtube-player',
            type: 'text/html',
            allowfullscreen: true
        }).css({'position': 'absolute', 'top': '11px', 'left': '11px'}).appendTo(this);

        $(this).find('img').fadeOut(function() { $(this).remove();});

     });

    });
</code></pre>

<p>This code works well, the only problem is now I need to switch the url dynamically...and the variable is with php.</p>

<pre><code>&lt;?php 

$url = get_post_meta($id, $youtube[$number], true); // wordpress function 

?&gt;
</code></pre>

<p>How do I pass the url from php to javascript? Do I just do a jquery ajax call?</p>
