Here's a snippet for asynchronous javascript:
var bsa = document.createElement('script');
bsa.type = 'text/javascript';
bsa.async = true;
bsa.src = 'myfile.js';
bsa.test_var = 'HI!';
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(bsa);
I added the line bsa.test_var = 'HI!'; - I've tried to pass parameters into the myfile.js and there print out the 'test_var', but it doesn't work.
In the myfile.js, I've tried to call alert(bsa.test_var) or just alert(test_var), but neither one version didn't work.
Is there any way to pass parameters? I would like to pass parameters into the myfile.js and there according to the parameter load data the appropriate data from database.
Thank you
bsa.src = 'myfile.js?key1=val&key2=val'?