I have this bit of code. I want it to download the .js file and then run it. wWen it starts, I want it to return a parameter or even a better object.
This is the code on my page
var runCode = function(){
var xhr=new XMLHttpRequest();
xhr.open('GET','io.js',false);
xhr.send();
return eval(xhr.responseText);
};
And this is.js
var IO = new function(){
this.run = true;
return 'io';
};
return IO
But when I run it, I get the message "Uncaught SyntaxError: Illegal return statement" in the console.
source
share