I have a database which contains several data that is continually updated with new ones… The result i want is whenever the database has a new data, the page automatically retrieves the data in the database (via AJAX, so no page reloading is involved) and display it to the page.
Of course, I can use
setInterval(function(){
// Query Database
// Show to page
}, xTime);
But it doesnt seem to be efficient since i cant select the text / highlight the contents in the page because its updated every time… Is there another way i can do this?
An example for this functionality is m.facebook.com 's message page… It sends the message you typed and whenever you receive a new message, it just displays it without loading, and am sure it doesnt use setInterval since i can select all of the text! Thanks!