[Answer]-Ajax to notify about variable change on server

1👍

Approach 1 which you specify is called polling and which will generate multiple calls to server so it is not recommended.

Approach 2 is not feasible since you will have time out.

Right way(efficiently) to do this type of thing is via WebSockets or some kind of Push Notification from server. few libraries are
http://socket.io/
https://github.com/SignalR/SignalR/wiki/Faq

If this had helped you don’t forgot to mark it as answer 🙂

0👍

Polling is simplest option since it will work with plain Django system.

There exists several other techniques to keep connection open and send messages to client (browser), like websockets or server sent events (sse), but those require additional components in infrastructure than just Django.

And you can’t keep server waiting, browsers and frontend webservers usually do have time limits to detect dead connections so your connection would be terminated before game starts.

👤jtiai

0👍

Your server knows when the game will start, like 5pm? Tell the browser’s JavaScript to start polling at 4:59:40

👤Josh

Leave a comment