简体   繁体   English

从JSONP JavaScript获取数据

[英]get data from JSONP javascript

I've got JSONP server response: 我有JSONP服务器响应:

({"Info":"([["xxx",false,"",2,false,null],["yyy","zzzi","123456789","example@com","http://www.e-yyy.pl","example@com","img.jpg",null],["os","aaa","bbb","ccc",null,null,null],["xx_2012","www",2012,2012,2,[["yy_2012",null],["zz_2012",[["dk2","ccc1",1,123.5,null]]]]]])"})

How can I get example@com from it? 如何从中获取example @ com?

You can use eval(), despite it have security problems. 您可以使用eval(),尽管它存在安全问题。 Example: 例:

//sample
var response_data = '({"Info": 1})';
alert(eval(response_data).Info);

But I think the best is to strip the () and use JSON.parse, as said in the comments section. 但是我认为最好的方法是删除()并使用JSON.parse,如评论部分所述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM