用于FullCalendar的JSON查询或JavaScriptSerializer
使用fullcalendar JQuery模型 如果我手动输入javascript对象,效果会非常好:用于FullCalendar的JSON查询或JavaScriptSerializer,fullcalendar,Fullcalendar,使用fullcalendar JQuery模型 如果我手动输入javascript对象,效果会非常好: $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, editable: tru
$('#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”文件中的代码:
来自ashx JSON处理程序的代码:
context.Response.Write(JsonConvert.SerializeObject(new
{
items = new[] {
new {title = "command" , start = "2014-03-12"},
new {title = "command2" , start = "2014-03-13"}
}
}));
有什么想法吗?修复了它,这是一件非常愚蠢的事情,我使用的是context.Response.ContentType=“application/json”;而不是context.Response.ContentType=“text/html”;
context.Response.Write(JsonConvert.SerializeObject(new
{
items = new[] {
new {title = "command" , start = "2014-03-12"},
new {title = "command2" , start = "2014-03-13"}
}
}));