javascript - Calling a function and pass it a json object -


i have json object named data below

enter image description here

and have function denomination in string below

enter image description here

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); } 

example fiddle

this assumes function has global scope.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -