我试过了,但我无法解析这个来自ashx页面的json对象。我使用javascript序列化程序序列化列表。我显示了返回的json,但当我试图解析它时,它只显示了对象对象,对象对象。如果我在ashx页面将结果更改为这个,并返回字符串"{ \"Appointment\":"+ return +"}“,则jquery不会将post视为成功,也无法解析它。我使用jquery 1.7.1.min.js,但无法解析json。我使用的是我使用的方法和我试图解析的it.These对象
$.ajax({
type: "POST",
url: "getappointment.ashx",
data: { StartTime: timec },
dataType: "Text",
success: function (msg) {
var result = jQuery.parseJSON(msg);
for (var i in result) {
alert(result[i].appointmentID)
}
}
});
1)
parsed= $.secureEvalJSON(JSON.stringify(json));
alert(parsed.Appointment[1].appointmentID);
2)
$.each(json.Appointment, function (i, app) {
alert(json.app.appointmentID.toString());
3)
var test = jQuery.parseJSON(msg);
alert(test[0].appointmentID);
4)
$.each(msg, function () {
$.each(this, function (k, v) {
...
});
});
Json对象
[{"appointmentID":"4","coachid":"1","equipmentid":"1","starttime":"18.03.2012 19:14:28","endtime":"18.03.2012 19:14:28"},
{"appointmentID":"8","coachid":"1","equipmentid":"1","starttime":"18.03.2012 19:00:00","endtime":"18.03.2012 19:14:28"}]
发布于 2012-03-26 09:08:13
您不需要解析任何东西-您已经准备好使用JSON对象了。
发布于 2012-03-26 06:14:49
试试var test = JSON.parse(json);
https://stackoverflow.com/questions/9864551
复制相似问题