我使用jQuery插件fullcalendar,我试图从答案没有运气其他问题改变这许多不同的方式,这是我的jQuery:jQuery是不是JSON解析响应正确
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
theme: true,
aspectRatio: 3,
height: 1000,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
events: function (start, end, callback) {
$.ajax({
type: "POST",
url: "Default.aspx/GetEvents",
data: "{'userID':" + "'B473795D-306A-4718-804B-2813884D5B48'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (doc) {
var events = [];
var obj = $.parseJSON(doc.d);
var res = unescape(obj);
$(res).find('event').each(function() {
events.push({
title: $(this).attr('title'),
start: $(this).attr('start') // will be parsed
});
});
callback(events);
}
});
}
});
});
这里是我的回应:
{"d":"[{ \"title\" : \"circleJerk\", \"start\" : \"2012-06-22\" }, { \"title\" : \"BangTheWife\", \"start\" : \"2012-06-15\" , \"end\" : \"2012-06-23\" } ]"}
什么是'unescape'
events
选项。我不认为你需要它 – Rab我试过没有它,只是因为\“ –
然后你不认为你应该在parsejason之前使用它 – Rab