Despite a mountain of posts on the subject, I'm having no luck getting embedded php to echo out into a JS variable. Even stripped down to:
//PHP from app.php
$data = json_encode(5);
//and JS in results.html
var data = <?php echo $data; ?>;
console.log only produces "SyntaxError: expected expression, got '<'". With quotes around the
It seems that the PHP isn't parsing. As Ed Cottrell points out below, there's a here remains unpopular and unanswered. I ran the test.php created by pemcconnell and that works for me. He says that suggests "another problem with your JS" but my JS is working just fine otherwise.
So... I throw myself to the wolves. What stupid thing am I doing? If anyone can help I will make an altar in their honor, complete with garlands and incense.