Hello,
I have this json, and when i get this json i need to run the function which comes at callback object.
{
formId: 'snn_service_item_form',
item_id: '1',
item_title: 'some item',
item_description: '',
item_duration: '10',
item_price: '120',
item_level_1 : 1,
item_level_2 : 0,
item_level_3 : 1,
item_type: 'p',
callback : {
callbackName : 'getServices',
callbackParams : {
_param1 : 1,
_param2 : 2
}
}
}
so according to this i need to run this:
getServices(1,2);
i can do that with eval function like:
eval(json.callback.callbackName+'(\''+ json.callback.callbackNParams._param1 +'\',\''+ json.callback.callbackNParams._param2 +'\')');
i can automate this by putting it into a for in and writing parameters to a string, but i dont think this is the best way to go.
is there a way to assign function name from a var and giving its parameters as an object, in my case like:
json.callback.callbackName(json.callback.callbackParams);
i know this is not the way to do it but it is what i want to learn.
Thanks, Sinan.