I have this array ($test) in PHP
array (size=4)
1 => string '[email protected]' (length=17)
2 => string '[email protected]' (length=17)
3 => string '[email protected]' (length=17)
4 => string '[email protected]' (length=17)
And want to pass it to javascript. My goal is to use this in a AJAX query.
So I did the following
var test = "<?php echo json_encode($test); ?>";
$.post("../path/to/file.php",
{
test: test,
},
function(data,status)
{
...
});
But the following is triggering everytime
SyntaxError: missing ; before statement
var test = "{"1":"[email protected]","2":"test1@mail.
var test = "<?php echo json_encode($test); ?>"? Your code example is not complete, there is novar inputas stated in you error message.