I am getting a really weird JavaScript error when I run this code:
<script type = 'text/javascript'>
var ask = confirm(<?=json_encode($message, JSON_HEX_TAG); ?>);
if (ask == false)
{
return false;
}
else
{
return true;
}
</script>
In the JavaScript console it says:
Syntax Error: Illegal return statement
It occurs at return true; and return false;
(I am echoing this JavaScript from a PHP function; the $message variable is one of the PHP parameters)
What is wrong with my code?
{or}.