I am developing fullcalendar for MVC Project. I tried everything json return no problem it works but events not showing in calendar.
Use
JavaScript: FullCalendar v5
MVC 5: Entity Framework
Please check Javascript Code
events: function (fetchInfo, successCallback, failureCallback) {
jQuery.ajax({
url: "GetEvents",
type: "GET",
dataType: 'json',
success: function (data) {
var events = [];
$.each(data, function (i, v) {
events.push({
id: v.id,
title: v.title,
start: moment(v.start).format('DD/MM/YYYY')
});
});
console.log(events);
successCallback(events);
}
});
}
});
calendar.render();
Please check also CONTROLLER Json Code
public JsonResult GetEvents()
{
using (var db = new Entities())
{
var events = db.NobEczanes.Include(x => x.Eczane).Select(asset => new
{
id = asset.EventID,
title = asset.Eczane != null ? asset.Eczane.Ad : "",
start = asset.Tarih
}).ToList();
return new JsonResult { Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
}
Please check Chrome Console Debugger Log
UPDATE: CONSOLE LOG DETAILS! Please Check Image Links Thanks!
Visual Studio Breakpoint Result
Last Update Javascript Code and Effect start value but still same problem
$.each(data, function (i, v) {
debugger;
events.push({
id: v.id,
title: v.title,
start: moment(v.start).format('DD/MM/YYYY')
});
Check Last Console Log
CodePudding user response:
Here issue depend via Date Format
Solution!
start: moment(data.start).format("YYYY-MM-DD")
It work fine thanks.