我在asp.net应用程序中使用jquery fullcalendar。请参阅代码-ASPX代码
$('#calendar').fullCalendar({
editable: true,
events: "SchedulerJsonResponse.ashx",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' daysn' +
'(should probably update your database)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
});
SchedulerJsonResponse.ashx-
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
string res = scheduleTest.getAllScheduledSessionsOfLocation();
context.Response.Write(res);
context.Response.Flush();
context.Response.Close();
}
在上面的代码中,scheduleTest.getAllScheduledSessionsOfLocation()
方法返回如下。字符串到处理程序-
[{title: 'Puneet sdfsdfsdf',allDay:false,start: '02/20/2012 1:30:00 PM',end: '02/20/2012 2:00:00 PM'},{title: 'abc xyz',allDay:false,start: '03/05/2012 6:00:00 AM',end: '03/05/2012 6:00:00 AM'},{title: 'bhuvana ',allDay:false,start: '03/07/2012 7:30:00 PM',end: '03/07/2012 7:30:00 PM'},{title: 'bhuvana ',allDay:false,start: '03/12/2012 2:00:00 PM',end: '03/12/2012 2:00:00 PM'},{title: 'abc xyz',allDay:false,start: '03/12/2012 6:00:00 AM',end: '03/12/2012 6:00:00 AM'},{title: 'bhuvana ',allDay:false,start: '03/14/2012 7:30:00 PM',end: '03/14/2012 7:30:00 PM'},{title: 'bhuvana ',allDay:false,start: '03/19/2012 2:00:00 PM',end: '03/19/2012 2:00:00 PM'},{title: 'abc xyz',allDay:false,start: '03/19/2012 6:00:00 AM',end: '03/19/2012 6:00:00 AM'},{title: 'bhuvana ',allDay:false,start: '03/21/2012 7:30:00 PM',end: '03/21/2012 7:30:00 PM'},{title: 'bhuvana ',allDay:false,start: '03/26/2012 2:00:00 PM',end: '03/26/2012 2:00:00 PM'},{title: 'abc xyz',allDay:false,start: '03/26/2012 6:00:00 AM',end: '03/26/2012 6:00:00 AM'},{title: 'bhuvana ',allDay:false,start: '03/28/2012 7:30:00 PM',end: '03/28/2012 7:30:00 PM'},{title: 'bhuvana ',allDay:false,start: '04/02/2012 2:00:00 PM',end: '04/02/2012 2:00:00 PM'},{title: 'abc xyz',allDay:false,start: '04/02/2012 6:00:00 AM',end: '04/02/2012 6:00:00 AM'},{title: 'bhuvana ',allDay:false,start: '04/04/2012 7:30:00 PM',end: '04/04/2012 7:30:00 PM'},{title: 'bhuvana ',allDay:false,start: '04/09/2012 2:00:00 PM',end: '04/09/2012 2:00:00 PM'},{title: 'abc xyz',allDay:false,start: '04/09/2012 6:00:00 AM',end: '04/09/2012 6:00:00 AM'},{title: 'bhuvana ',allDay:false,start: '04/11/2012 7:30:00 PM',end: '04/11/2012 7:30:00 PM'},{title: 'bhuvana ',allDay:false,start: '04/16/2012 2:00:00 PM',end: '04/16/2012 2:00:00 PM'},{title: 'abc xyz',allDay:false,start: '04/16/2012 6:00:00 AM',end: '04/16/2012 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '03/24/2014 6:00:00 AM',end: '03/24/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '03/31/2014 6:00:00 AM',end: '03/31/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '04/07/2014 6:00:00 AM',end: '04/07/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '04/14/2014 6:00:00 AM',end: '04/14/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '04/21/2014 6:00:00 AM',end: '04/21/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '04/28/2014 6:00:00 AM',end: '04/28/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '05/05/2014 6:00:00 AM',end: '05/05/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '05/12/2014 6:00:00 AM',end: '05/12/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '05/19/2014 6:00:00 AM',end: '05/19/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '05/26/2014 6:00:00 AM',end: '05/26/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '06/02/2014 6:00:00 AM',end: '06/02/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '06/09/2014 6:00:00 AM',end: '06/09/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '06/16/2014 6:00:00 AM',end: '06/16/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '06/23/2014 6:00:00 AM',end: '06/23/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '06/30/2014 6:00:00 AM',end: '06/30/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '07/07/2014 6:00:00 AM',end: '07/07/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '07/14/2014 6:00:00 AM',end: '07/14/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '07/21/2014 6:00:00 AM',end: '07/21/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '07/28/2014 6:00:00 AM',end: '07/28/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '08/04/2014 6:00:00 AM',end: '08/04/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '08/11/2014 6:00:00 AM',end: '08/11/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '08/18/2014 6:00:00 AM',end: '08/18/2014 6:00:00 AM'},{title: 'rtew ',allDay:false,start: '08/25/2014 6:00:00 AM',end: '08/25/2014 6:00:00 AM'}]
但在日历中,它没有显示任何事件。我在fullcalenders事件中硬编码了响应,然后它工作正常。请帮我解决它。
Abhi您需要在键和值对周围都有双引号。。。例如
[{"title":"Puneet-sdfsdfsdf","allDay":false,"start":"02/20/2012下午1:30:00","end":"02.20/2012下午2:00:00"},…etc
由于所有事件都有开始日期和结束日期,您可以使用allDayDefault:false,而不在json提要中包含"allDay":false。
此外,我还遇到了一些日期时间格式的问题,在一些浏览器中,事件会在其他浏览器中显示,使用的是事件没有显示的提要。我最终使用了"2012-02-20T13:30:00+000",它适用于我测试的所有浏览器。