I currently have two files named data1.js and data2.js. In data1.js, there is a variable defined as:
var rows = ['g1', 'g2'];
Whereas in data2.js, the variable is defined differently as:
var rows = ['g1', 'g2', 'g3', 'g4'];
Initially, I load data1.js using the following script tag:
<script id="datascript" type="text/javascript" src="data1.js"></script>
However, when a button is clicked, I try to load data2.js hoping it will update the variable rows with its contents:
onclick="datascript.src='data2.js';alert(rows);"
Unfortunately, despite changing the script source to data2.js, the rows variable does not update as expected. What could be causing this issue?
Thank you.