I have a function in my html file that has a javascript script runnning a function. I would like to take some of the variables from that function, and get them into the javascript file.
I already looked at the global variable as well as window, but both of them return an undefined variable, even though it has been set in my function in HTML. Below is part of the code showing the function in HTML and project_id is one of the variables id like in my javascript file. both my html and javascript file have the same name.
reader.onload = (function(theFile) {
return function(e) {
//var test;
// global.test = "hi";
var results = e.target.result;
var obj = JSON.parse(results);
project_id = obj.project_id;
client_email = obj.client_email;
// private_key = obj.private_key;
//make it a hidden element
// Print the contents of the file
var span = document.createElement('span');
span.innerHTML = ['<p id= "data">',e.target.result,'</p>'].join('');
document.getElementById('list').insertBefore(span, null);
};
})(f);