我使用发送回字符串的ajax ..
我想将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"}]
答案 0 :(得分:2)
答案 1 :(得分:1)
将strJSON
更改为response
。