I have an HTML loading multiple scripts:
<html>
<head>
<script src="scriptDeclaringAGlobalVar.js"></script>
<script src="scriptReadingAGlobalVar.js"></script>
...
scriptDeclaringAGlobalVar.js:
var aGlobalVar = "hello"
scriptReadingAGlobalVar.js:
$(document).ready(function(){
console.log(aGlobalVar);
});
Though the global variable is declared in the first script, and even $(document).ready
was used, it can't be reached, I get errors like this in HtmlUnit:
jQuery.Deferred exception: "aGlobalVar" is not defined. @http://localhost:8080/scriptReadingAGlolbalVar.js:2
@https://code.jquery.com/jquery-3.7.0.js:3479
@https://code.jquery.com/jquery-3.7.0.js:3547
The same works fine in browsers.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too