0

I am taking values from sensor at an interval of 1 second. These values are being stored in MySQL DB. This is an automatic process.

Now I have made a website(free hosting) to show these values. The problem is, to see the updated values i have to refresh the browser. But I want the values to update automatically without refreshing the browser.

I am using PHP and MySQL

I have searched online and I saw some AJAX tutorials. But in those tutorials, you have to do something(Press a button) to update the values without refreshing the page. I want to update the values as soon as they are updated in the DB automatically.

Any help would be appreciated.

  • 1
    js\ajkax is the way to go, you need the client side to poll the server side –  Jun 22 '19 at 06:59
  • You can set a timer in Javascript to cause the AJAX function to be called. (i.e. https://stackoverflow.com/questions/4542863/jquery-ajax-call-with-timer) – Nigel Ren Jun 22 '19 at 07:02
  • Possible duplicate of [how to schedule ajax calls every N seconds?](https://stackoverflow.com/questions/1350446/how-to-schedule-ajax-calls-every-n-seconds) – ordonezalex Jun 22 '19 at 07:10

1 Answers1

0

You can do this with jQuery/AJAX, you’ll have to learn a bit to do this but it is very easy. What you should do is this, in js:

$.post("filename.php",{parameter:value}, function(data) {.$("elm").html(data);});

Something like this. You put it in a function and the you write this at the end of the script

setInterval(yourfunction(), time)

And then everything is ok. Go check a little lesson of jQuery, and you should understand this

hintauh
  • 72
  • 2
  • 9