Here is how I am getting event information from my database into FullCalender, using PHP:
- Query database for event information.
- Place that information into an array and make my formatting edits, add colors, whatever.
- Use json_encode to put array into JSON format.
- Write the file to my server as "results.json".
Then in my javascript I use this file to fill my Calendar object:
$('#calendar').fullCalendar({
events: 'results.json'
});
So that all works great.
Here is my concern:
What happens when I have multiple users?
Jim is going to query the database for his events. Those events are going to be written to results.json.
At the same time, Sue may open the page and query the database for her events. The code is going to overwrite results.json.
Who knows what events are going to show up on their calendar!
I see some suggestions about using socket.io, but there are other articles suggesting that people should be moving to use WebSockets. And I understand that these are supposed to help with real-time applications.
But I'm not following a chat session that is being updated real-time. I have many users that are accessing their own data. Does that mean that every user needs to have their own JSON file? That seems... yucky. Should this file be saved to their local device? That seems full of permission issues.
Any advice?
and then accessing it from javascript with "document.getElementsByClassName('JSON_result'), but that didn't work. But YES, that would totally solve my problem. How do you do that?
– B. Krafft Mar 02 '17 at 16:57