I want to pass two function names to a function with JSON, but can't get it to work. I'm in over my head with this stuff.
Here are my functions. myFunc is supposed to call the two functions that are passed to it (myBefore and myAfter).
function myFunc(obj) {
var func = $.parseJSON(obj);
if (typeof func[before] === "function") func[before]();
// do some stuff
if (typeof func[after] === "function") func[after]();
}
function myBefore() {
alert("before");
}
function myAfter() {
alert("after");
}
and here is how I'm calling myFunc
myFunc({"before": "myBefore", "after" :"myAfter"});