javascript - Calling a function and pass it a json object -
i have json object named data below
and have function denomination in string below
test name of function call , pass json object data.
here test function:
test = function (data) { alert('i test function'); }
i try:
eval(func(data));
it doesn't work.
any idea?
thanks.
while eval()
1 possible solution, awful.
instead, interrogate window
find function want , run there:
function test() { alert("test") } var func = $("#confirm-remove").data("success"); var data = {}; // object var fn = window[func]; if (typeof fn === 'function') { fn(data); }
this assumes function has global scope.
Comments
Post a Comment