I
I
ikari812014-02-26 05:13:35
PHP
ikari81, 2014-02-26 05:13:35

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

5 answer(s)
A
Alexander S, 2014-02-26
@FirstX

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.

R
Ruslan Kasymov, 2014-02-26
@HDAPache

javascript.ru/ajax/transport/xmlhttprequest
en.wikipedia.org/wiki/XMLHttpRequest

A
akashtrih, 2014-02-26
@akashtrih

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 .

C
connected201, 2014-03-31
@connected201

Why hasn't the issue been closed yet? Ajax to help you my dear friend

A
Andrey Burov, 2015-05-22
@BuriK666

php.net/manual/ru/book.pdo.php
php.net/manual/ru/book.mssql.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question