Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use AJAX to watch SQL database for changes [closed]

Tags:

jquery

ajax

sql

I have a column in my database that will be updated randomly. Whenever that column is updated I need to refresh content on my page. How can I use AJAX + jQuery to perform an action only on DB changes?

like image 470
Jacob Huggart Avatar asked May 11 '10 18:05

Jacob Huggart


People also ask

Which object can be used to retrieve data in AJAX?

XMLHttpRequest (XHR) objects are used to interact with servers. You can retrieve data from a URL without having to do a full page refresh. This enables a Web page to update just part of a page without disrupting what the user is doing. XMLHttpRequest is used heavily in AJAX programming.

What is the replacement of AJAX?

With interactive websites and modern web standards, Ajax is gradually being replaced by functions within JavaScript frameworks and the official Fetch API Standard.


2 Answers

What you are describing is colloquially called Comet programming. Comet describes a group of techniques for pushing content to a web page with a persistent HTTP connection.

The push would be initiated using a trigger/stored procedure combination in the database server. That way, it occurs no matter where the data update comes from.

like image 115
Robert Harvey Avatar answered Sep 29 '22 00:09

Robert Harvey


use setinterval function of javascript for polling and to check the value of the updated dababase field

check following link for more detail http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/

like image 31
Pranay Rana Avatar answered Sep 29 '22 01:09

Pranay Rana