Прежде всего, я бы сказал, что я пробовал множество примеров здесь и других, но не получил успеха, поэтому отправляю сюда для предложения.
Я использую полный календарь.
Вот начало:
$('#calendar')
.fullCalendar({
allDaySlot: false,
customButtons: {
reload: {
text: '+1 Year',
click: function() {
$('#calendar').fullCalendar('gotoDate', new Date(new Date().setFullYear(new Date().getFullYear() + 1)));
}
}
},
themeSystem: 'bootstrap4',
defaultView: 'agendaWeek',
eventClick: updateEvent,
selectable: true,
selectHelper: true,
events: "JsonResponse.ashx",
and other attributes.....
Проблема в том, что в календаре не отображаются события.
JsonResonse.ashx возвращает строку типа:
[{id: '1029',title: 'mr 1',clientphone: '1234556654',clientemail: 'mr1@gmail.com',start: '2018-05-21 10:00',end: '2018-05-21 11:45',allDay:false,description: 'New test on a new calender'},{id: '1030',title: 'mr 2',clientphone: '123456',clientemail: 'mr2@gmail.com',start: '2018-05-25 09:00',end: '2018-05-25 11:45',allDay:false,description: 'i like pringles'}]
Однако в Firefox я вижу, что это не делает события ошибкой, говоря:
SyntaxError: JSON.parse: expected property name or '}' at line 1 column 3 of the JSON data
Итак, я беру события и Replace: "JsonResponse.ashx", с возвращенной строкой
[{id: '1029',title: 'mr 1',clientphone: '1234556654',clientemail: 'mr1@gmail.com',start: '2018-05-21 10:00',end: '2018-05-21 11:45',allDay:false,description: 'New test on a new calender'},{id: '1030',title: 'mr 2',clientphone: '123456',clientemail: 'mr2@gmail.com',start: '2018-05-25 09:00',end: '2018-05-25 11:45',allDay:false,description: 'i like pringles'}]
КОД ДЛЯ ВОЗВРАТА JSON:
return "{" +
"id: '" + cevent.id + "'," +
"title: '" + HttpContext.Current.Server.HtmlEncode(cevent.title) + "'," +
"clientphone: '" + HttpContext.Current.Server.HtmlEncode(cevent.clientphone) + "'," +
"clientemail: '" + HttpContext.Current.Server.HtmlEncode(cevent.clientemail) + "'," +
"start: '" + (cevent.start).ToString("yyyy-MM-dd HH:mm") + "'," +
"end: '" + (cevent.end).ToString("yyyy-MM-dd HH:mm") + "'," +
"allDay:" + allDay + "," +
"description: '" + HttpContext.Current.Server.HtmlEncode(cevent.description) + "'" +
"},";
По сути, я объединяю всесобытия, а затем вернуться.
просто так, и он отлично работает и помещать события в календарь.Что я здесь не так делаю?
Спасибо