Consider the following Jquery external script snippet for creating youtube iframes in modal windows:
$(function() {
$(document).ready(function() {
var myPhpVa = '<?php echo embeddable($ytid);?>';
$('a[name="modal"]').click(function(e) {
$('<iframe width="560" height="315" src=myPhpVa frameborder="0" allowfullscreen>').appendTo('#dcontent');
}
});
For some reason I get object not found. The PHP function is declared above this javascript, the declaration is:
function embeddable($ytid){
return $embeddable = 'http://www.youtube.com/embed/'.$ytid;
}
Any help for passing this PHP variable is greatly appreciated.
First of all – assigning returned value is useless. Remove it:
The same thing about
$(document).ready(function() {and$(function() {– they are equal and doubled – remove one of them.After you assign
myPhpVavariable – writeand check what it shows you.