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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -