I have a textarea
where the messages put by user1 and user2 are placed , what I want is that every so often, for example 5 seconds, div
only the user is updated.
For this I have found several examples where they use load
passing a page to load.
$(document).ready(function() {
var refreshId = setInterval(function() {
$("#feedback-bg-info").load("url a cargar")
.error(function() { alert("Error"); });
}, 1000);
$.ajaxSetup({ cache: false });
});
In this part $("#feedback-bg-info").load("url a cargar")
, in the method load
, what I am looking for is that only the is updated div
without passing it a different route.
To update the div only, the setInterval() function you are using is a perfect fit for what you want since it calls a function or evaluates an expression at a specified time interval expressed in milliseconds. Now replicating what you propose, I show the following page:
with the expression:
You would only be updating the div of your page, since you are calling the id with which you defined it. In the load enter the link of your current page.
I leave you a link to a similar question Here I hope it works for you!
You can do the following:
More information: JAVASCRIPT FUNCTIONS – SETINTERVAL() CLEARINTERVAL() SETTIMEOUT()