ASP返回JSON的问题

2014 年 3 月 4 日3830

response.asp
response.Write "{totalCount:1,data:[{Name:\"null\",Title:\"按时大味道\",Content:\"按时大味道\",Answer:\"呜呜呜56t456\",Show:\"True\",SaveTime:\"2010/8/11\"}]}"
get.js
$.ajax({url: "/response.asp",data: "id="+id,
success: function(x) {
if(typeof(x)!="undefined" && x!="Error"){
var json=eval("("+x+")"); ////这句出错
}
}
});
请问在ASP要response什么样的格式,js文件才能将接收的字符串转为json对象?

------回答---------

------回答(20分)---------

<%
response.Write "{totalCount:1,data:[{Name:""null"",Title:""按时大味道"",Content:""按时大味道 "",Answer:""呜呜呜56t456"",Show:""True"",SaveTime:""2010/8/11""}]}"
%>

------回答(20分)---------

response.asp
response.Write "{totalCount:1,data:[{Name:\"null\",Title:\"按时大味道\",Content:\"按时大味道 \",Answer:\"呜呜呜56t456\",Show:\"True\",SaveTime:\"2010/8/11\"}]}"
get.js
$.ajax({url: "/response.asp",data: "id="+id,dateType:"json",
success: function(x) {
if(typeof(x)!="undefined" && x!="Error"){
var json=eval("("+x+")"); ////这句出错
}
}
});

------回答---------

------回答(20分)---------

<%
response.Write "{totalCount:1,data:[{Name:""null"",Title:""按时大味道"",Content:""按时大味道 "",Answer:""呜呜呜56t456"",Show:""True"",SaveTime:""2010/8/11""}]}"
%>

------回答(20分)---------

response.asp
response.Write "{totalCount:1,data:[{Name:\"null\",Title:\"按时大味道\",Content:\"按时大味道 \",Answer:\"呜呜呜56t456\",Show:\"True\",SaveTime:\"2010/8/11\"}]}"
get.js
$.ajax({url: "/response.asp",data: "id="+id,dateType:"json",
success: function(x) {
if(typeof(x)!="undefined" && x!="Error"){
var json=eval("("+x+")"); ////这句出错
}
}
});

0 0