Passing javascript to a function
- by AJ
Hello,
Can I pass some Javascript to a function and then execute that Javascript from within the function, e.g.
test("a = 1; b = 2; test2(a,b);");
function test(js) {
// execute dynamically generated JS here.
}
Basically I have some code that is generated on the server and I want to pass that code to a JS function which when it has finished processing it executes the code passed as a parameter.
This could also be useful for the parameter of setTimeout, then the code passed could be executed in the timeout event.
Can this be done?