I have an PHP file that I want to pass a parameter from it to a JavaScript file , it seems simple but I just can't execute it , my way doesn't work and I don't know why!!
These are the codes of the 2 files plus another HTML code to view the result ,,`
the php file ..
<?php
$ser = "server";
?>
<script type="text/javascript">var server = "<?= $ser ?>";</script>
<script type="text/javascript" src="new4.js"></script>
new4.js (the Java script file)
function myFunction() {
alert("server: " + server);
}
And this's the HTML file to view the result
<!DOCTYPE html>
<html>
<body>
<script src="new4.js"></script>
<p>Click the button to demonstrate line-breaks in a popup box.</p>
<button onclick="myFunction()">Try it</button>
</body>
</html>