Answer the question
In order to leave comments, you need to log in
How to implement page content update without reloading it?
There is a RasPi, 18b20 are connected to it via 1-w, collecting the temperature in all rooms. Lamp is installed, the php page collects data from all sensors, but it itself is static. How can I make sure that the information on the page is updated without reloading it (like the temperature on the mail.ru main page or notifications about letters)?
Answer the question
In order to leave comments, you need to log in
Add an AJAX request to the page, which will asynchronously send a request to the web server on a timer (for example, a php function that collects data from sensors and returns them, say, in JSON format). After the data is received, your method is triggered, written in javascript for such a case, which changes the values in the displayed html code.
Of course, the easiest way is to make an AJAX request based on JQuery $.ajax, but for your task it is quite possible to insert a block of code in pure javascript that sends a request and processes the data received in response.
javascript.ru/ajax/transport/xmlhttprequest
en.wikipedia.org/wiki/XMLHttpRequest
Why are you interested in it without a reboot? You can solve it more simply: add a meta refresh tag to auto-refresh the page after a certain time interval (in seconds).
Well, if you really need it without reloading the page, you can use AngularJS , which is well suited for one-page sites. There are methods for working with ajax .
Why hasn't the issue been closed yet? Ajax to help you my dear friend
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question