0
我正在處理日曆模塊,並且無法將事件從控制器加載到完整日曆。這是我的代碼。通過json和ajax從控制器獲取事件到完整日曆
這裏的控制器類:
public JsonResult PublicHolidayList()
{
List<Event> events = new List<Event>();
events.Add(new Event()
{
EventName = "EventName 1",
StartDate = DateTime.Now.ToString("MM-dd-yyyy"),
EndDate = DateTime.Now.AddDays(2).ToString("MM-dd-yyyy")
});
events.Add(new Event()
{
EventName = "EventName 2",
StartDate = DateTime.Now.AddDays(4).ToString("MM-dd-yyyy"),
EndDate = DateTime.Now.AddDays(5).ToString("MM-dd-yyyy")
});
events.Add(new Event()
{
EventName = "EventName 3",
StartDate = DateTime.Now.AddDays(10).ToString("MM-dd-yyyy"),
EndDate = DateTime.Now.AddDays(11).ToString("MM-dd-yyyy")
});
events.Add(new Event()
{
EventName = "EventName 4",
StartDate = DateTime.Now.AddDays(22).ToString("MM-dd-yyyy"),
EndDate = DateTime.Now.AddDays(25).ToString("MM-dd-yyyy")
});
return Json(events, JsonRequestBehavior.AllowGet);
}
這是腳本:
$(function() {
$.ajax({
type: "POST",
contentType: "application/json",
data: "{}",
url: "/Leave/PublicHolidayList",
dataType: "json",
success: function(data) {
alert(data);
$('#calendar_ph').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultView: 'month',
editable: true,
events: data,
height: 650
});
},
error: function() {
}
});
})
.done(function (data) {
});
有人能親切地解釋爲什麼事件是不是在我的日曆顯示?
非常感謝moment.js。完美地工作。 –
隨時...快樂編碼.. :) –