Olga Real Olga Real - 1 year ago 87
Ajax Question

JSON that contains functions

I have a website that returns a JSON-like data structure like this:

"name":"tom jones",
"no": 123,
"storedproc": function(){

I'm getting this data using
with dataType "JSON". Unfortunately, my
calls the error callback because my data contains a function().
How can I parse this correctly? I really need to store the function in a variable and call it later.

Answer Source

Could you arrange to have the server return JSON like this:

{"name":"tom jones",
  "no": 123,
 "storeprocFn": callbuyer,
 "arg": "0123"};

Then your callback function can call the callbuyer function and pass arg

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download