have facing error on full calendar display. I received JSON from a servlet in the following formats.
Type1: [["title2","2021-09-10","2021-09-10"],["title2","2021-09-10","2021-09-10"],
Type2: [["title2","2021-09-10","2021-09-10"],["title2","2021-09-10","2021-09-10"]]
Here's the error I see in Google chrome's console:
My code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.1.0/fullcalendar.js'></script>
<link rel='stylesheet' href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.1.0/fullcalendar.min.css" />
<div id='calendar'></div>
$(document).ready(function() {
var s = '';
var value;
var datavlue;
$.ajax({
url: 'CalendarEventController',
dataType: "json",
success: function(response) {
console.log(response);
value = response;
s = '[';
$.each(value, function(index, v) {
s += '["' + v.title + '","' + v.start + '","' + v.end + '"],';
});
console.log(s);
var d = s.slice(0, -1)
d += ']';
console.log(d);
datavlue = JSON.parse(d);
console.log(datavlue)
$('#calendar').fullCalendar({
// put your options and callbacks here
left: 'Calendar',
center: '',
right: 'today prev,next',
editable: true,
events: [datavlue],
})
}
});
});
If you keep response as the value for events the calendar should work
$(document).ready(function() {
var s = '';
var value;
var datavlue;
var response = [{title: 'title2', start: '2021-09-10',end:'2021-09-10'}, {title: 'title2', start: '2021-09-10',end:'2021-09-10'}]
$('#calendar').fullCalendar({
// put your options and callbacks here
left: 'Calendar',
center: '',
right: 'today prev,next',
editable: true,
events: response,
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.1.0/fullcalendar.js'></script>
<link rel='stylesheet' href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.1.0/fullcalendar.min.css" />
<div id='calendar'></div>