使用fullcalendar JQuery模型,
如果我手动输入javascript对象,则效果很好:
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
theme:true,
events : [
{
title: 'Event1',
start: '2014-03-12'
},
{
title: 'Event2',
start: '2014-03-1'
}
// etc...
],
但是当我使用JSON或JavaScriptSerializer ashx处理程序时,日历上没有显示任何内容。我错过了什么吗?或者我犯了一个愚蠢的错误:
来自页面调用JSON或JavaScript的代码 - 我实际上得到了对象并且可以看到它们而不是在日历上:
events:
{
url: $("#ASHXHandlerTextBox").val(),
type: 'POST',
data: {
startdate: $("#StartDateTextBox").val(),
calendar: $("#CalendarToUseTextBox").val(),
userid: $("#UserIdTextBox").val()
},
error: function() {
alert($("#ASHXHandlerTextBox").val());
},
success: function (data) {
for (var key in data) {
if (data.hasOwnProperty(key)) {
alert(key + " -> " + data[key]);
}
}
},
color: 'yellow', // a non-ajax option
textColor: 'black' // a non-ajax option
}
});
代码来自" ashx JavaScriptSerializer"文件:
JavaScriptSerializer js = new JavaScriptSerializer();
context.Response.Write(js.Serialize(new
{
items = new[] {
new {title = "command" , start = "Wed, 12 Mar 2014 "},
new {title = "command2" , start = "Thu, 13 Mar 2014 "}
}
}));
来自ashx JSON处理程序的代码:
context.Response.Write(JsonConvert.SerializeObject(new
{
items = new[] {
new {title = "command" , start = "2014-03-12"},
new {title = "command2" , start = "2014-03-13"}
}
}));
任何想法?