Global variable defined outside of javascript file does not work -
i have html file:
<body> <?php $rand1 = rand(0,10); $rand2 = rand(0,20); ?> <span id="client-registration-button">registration</span> <script>var checksum = <?php echo $rand1+$rand2; ?>;</script> <script src="/main.js"></script> </body>
and in main.js is:
$('#client-registration-button').click(function() { alert(checksum); });
but alert shows no value, empty alert window. why there no value of global variable "checksum" displayed?
Comments
Post a Comment