JavaScript AJAX Basics (retiring) Programming AJAX Processing JSON Data

Ilhyun Jo
Ilhyun Jo
6,288 Points

How do you keep the content up to date after loading once.

Even if you use the ever-changing database on the server to load the data, how can you make it so that the program keeps checking for changes on the database. It seems to me that once you load the program with data there's no method to check if the database ever changed afterwards. Is there a way to check without refreshing?

1 Answer

Kevin Korte
Kevin Korte
28,083 Points

Yes, but it starts to get a lot more complicated. The old school was was to poll the server in the background for changes. What that meant is that, client continued to ask the server for changes, and would ajax in whatever it got back. This of course is resource intensive on the server.

Than long polling, where the client made a request, and the request kinda lingered for awhile, until a change happend, or it was closed, and than a new poll would be started again.

Today, the best way is to use sockets, to establish a connection between client and server. With a socket, you'll live live updates. The framework Meteor.js has this built into it's core framework.

Ilhyun Jo
Ilhyun Jo
6,288 Points

Thanks I'll add Meteor.js to my studylist.

Kevin Korte
Kevin Korte
28,083 Points

Meteor is great. I'm using it in a project right now.