I have a AJAX with php that outputs different functions to run on the jquery side of things.
$.each(data['function'],function(key,value){
window[key](value)
}
data['function'] contains function data to run.
For example:
{"append":{"message":"hello","url":"link.com"}}
Will activate function
function append(message,url){...}
The problem is that {"message":"hello","url":"link.com"} is all contained in message. How can I translate or convert {"message":"hello","url":"link.com"} as parameters for the function?
right now it's running like this:
append({"message":"hello","url":"link.com"},undefined)
What is the solution to enable it to run like this:
append("hello","link.com")
I want to keep parameters intact append(message,url) and not resort to a single parameter method. I can't quite find a good solution.
Edited (Simplified)
How can I change Params object:
var Params={"message":"hello","url":"link.com"}
window['append'](Params);
To run the same as:
window['append']("hello","link.com")