I am having problems passing any kind of variable from PHP to JavaScript. Here is a simple example at jsFiddle. Why does it not return my string?
http://jsfiddle.net/funinabox/VkNe2/1/
<?php
//create php test string
$teststring = "mystring";
?>
//Convert Php string to JavaScript string
var testvar = <?php echo $teststring; ?> ;
//Display output of the array elements;
alert(testvar);
var testvar = "<?php echo $teststring; ?>";
– x4rf41 Apr 22 '13 at 13:50Uncaught SyntaxError: Unexpected token <
– jbabey Apr 22 '13 at 13:50