I tried but i was unable to parse this json object which comes from an ashx page.I use javascript serializer to serialize list.I showed the returned json just as it is but when i tried to parse it showed only [object Object],[object Object]. If i change the result to this at ashx page and return string "{ \"Appointment\":"+ return +"}" then jquery doesn't see the post as success and fails to parse it.I use jquery 1.7.1.min.js but there was no way of parsing it.These are the methods i used and the json object i tried to parse
$.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 object
[{"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"}]