PHP in External JS file (driving me crazy!)
I read several examples, tried them all out - and nothing works! Driving me crazy - completely insane! Maybe you guys can help :)
My problem is simple:
file B.html includes this line:
file B.js is a regular JS file, yet I need to insert a PHP function in it (yeah - I know it will operate server-side before the page reaches the browser). I did something like:
(What I expect is the browser to see the line as: var user_id = 300; )
(some js code)
var user_id = <?php $a=100; $b=200; $c=$a+$b; echo($c);?>;
alert("Your user ID is:" + user_id);
(some more js code)
Doesn't work. Renaming B.js to B.php did nothing.
What am I doing wrong?