I am using Fullcalendar V4. I am getting a problem with the eventSources option with PHP Ajax.
In Javascript I am using :
var eventSource = "data.php?value1=" + item_id;
calendar.addEventSource(eventSource);
From PHP I am sending :
echo '[{"id":"1","title":"All Day Event1","start":"2019-08-02","backgroundColor":"red"},{"id":"2","title":"All Day Eventssss2","start":"2019-08-04"},{"id":"3","title":"All Day Eventssss3","start":"2019-08-06"},{"id":"4","title":"All Day Eventssss4","start":"2019-08-08"}]';
This is working properly.
Now I want to use the option of eventSources, which is described here: https://fullcalendar.io/docs/event-source-object
For this, I am sending from PHP :
echo '[{"events" : [{"title" : "event1", "start" : "2019-08-01"},{"title" : "event2", "start" : "2019-08-05"}],"color" : "black"}]';
But this is not working. No error is showing in the console.
Please help!
echo '{"events" : [{"title" : "event1", "start" : "2019-08-01"},{"title" : "event2", "start" : "2019-08-05"}],"color" : "black"}';
calendar.addEventSource(eventSource);
indicates that you're already using that feature. The only difference is you're supplying a simple URL string to the function rather than a full object. This is allowed and valid. Unless you're planning to set some of the other properties of the event source object as well, then you don't actually have a need to change anything at all.