简体   繁体   中英

get data from JSONP javascript

I've got JSONP server response:

({"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?

You can use eval(), despite it have security problems. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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