PHP - AJAXLesson 81Free preview
AJAX Poll
This lesson is part of PHP · All levels
Summary
Polling means asking for data to the server periodically using the setInterval so that the display always displays the latest information, such as voting results or notifications. PHP endpoints process input sounds and then return the current data in JSON format. For the very frequent real-time needs, consider WebSocket or Server-Sent Events as a substitute for polling.
Key points
- SetInterval converts AJAX requests repeatedly at certain intervals.
- Endpoint voting must validate the input and return the latest data.
- Intervals are too often overloading the server, too rarely making the data dull.
- Technologies such as WebSocket or SSE are more economical for real-time updates.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.