+ -
当前位置:首页 → 问答吧 → 服务器返回json字符串后,在jquery里怎么无法调用啊。怎么转换成对象?

服务器返回json字符串后,在jquery里怎么无法调用啊。怎么转换成对象?

时间:2011-08-14

来源:互联网

服务器返回的字符串是:{"address":"china","name":"abc"}


我用jquery的post:
$.post("http://localhost:8080/testjquery/ok/testaction",function(data){
alert(data); //弹出:{"address":"china","name":"abc"}
alert(data.address); //没有显示,弹出undefine
},"text");
}


就是客户端接收到服务器返回的json字符串后,怎么转换成js的json对象,好通过对象.的方式访问数据。

作者: abcmsnet   发布时间: 2011-08-14

先用js的eval函数将data转为对象

作者: linminqin   发布时间: 2011-08-14

热门下载

更多