I found an answer to this and tried it but it did not work so I am posting this for more help. I posted a reply to the thread I found earlier but no one replied.
I am trying to write a game where you roll the dice and get half a quote and you have to guess if it matches the half that you were originally given. I am using AJAX and everything works fine right up until the end when I send a variable from php to javascript using echo '<script>currentQuote = $currentQuote;</script>'; It shows up on the page but when I check the value of currentQuote in JS it is undefined. Here is a link to a simplified version of the game just showing my problem.http://workwithu.com/Games/Game15snip.php The PHP code which you cannot see is:
$response = mt_rand(1,6);
echo $response;
echo '<script>currentQuote = $currentQuote;</script>';//this not working
echo "<br>";
echo "currentQuote is:";
echo $currentQuote; //this shows on the screen fine
Any help would be GREATLY appreciated. I have run out of ideas to try.