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?
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.
With interactive websites and modern web standards, Ajax is gradually being replaced by functions within JavaScript frameworks and the official Fetch API Standard.
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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With