javascript - Uncaught reference error for echo function in php -
i have used follwoing php code snippet inside java script code(inside parent html).
<script> function setoptions(d) { <?php echo "test"; ?> } </script>
when content saved , web page refreshed, following error,
uncaught referenceerror: test not defined
note- echo works when directly used inside html code.
any idea on how fix problem?
what want happen? when code parsed php sends browser (not valid javascript in function):
<script> function setoptions(d) { test } </script>
so produced needs valid javascript this:
<script> function setoptions(d) { <?php echo 'alert("test");'; ?> } </script>
would produce valid javascript:
<script> function setoptions(d) { alert("test"); } </script>
Comments
Post a Comment