1
我使用ajax发回一个字符串..如何将字符串转换为json对象?
我想将responsetext转换成一个json对象来处理。
我试过eval也是,但不起作用...
该怎么办?
我的代码是
function handleResponse() {
if(httpa.readyState == 4){
var response = httpa.responseText;
if(response!='empty')
{
alert(response);
var foo = eval('(' +strJSON+ ')');
alert (foo);
}
}
}
//响应警报
[{"id":"1","name":"Pepsodent 100g","selling_price":"28.75"},{"id":"2","name":"Pepsodent 40g","selling_price":"18.90"},{"id":"3","name":"Pepsodent brush","selling_price":"19.50"}]
手段?你可以给你一个代码样本 – Vijay 2010-05-06 18:20:49