JSON,它包含的功能 [英] JSON that contains functions

查看:132
本文介绍了JSON,它包含的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,返回一个类JSON数据结构是这样的:

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

{"name":"tom jones",
 "no": 123,
 "storeproc": function(){
                callbuyer(0123);
             }}

我得到这个数据使用 $。阿贾克斯()由于数据类型JSON。不幸的是,我的 $。阿贾克斯()调用错误回调,因为我的数据包含一个函数()。 我怎样才能正确地解析这个?我真的需要存储功能在一个变量和以后调用它。

I'm getting this data using $.ajax() with dataType "JSON". Unfortunately, my $.ajax() 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.

推荐答案

你能不能安排有这样的服务器返回JSON:

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

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

那么你的回调函数可以调用 callbuyer 功能,并通过 ARG

这篇关于JSON,它包含的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆