Reputation: 505
Can you help me, I will try to crud application in this one loaddata();
it's my function. any other user adds data then without refresh show in my table how to this possible.
function loaddata() {
$.ajax({
url : 'load.php',
type : 'POST',
success : function (data) {
$("#table-data").html(data);
}
});
}
This is my function any user adds data than this function automatically calls how to possible.
Currently after the refresh page show all data but I will try automatically showplace help me...
Upvotes: 3
Views: 971
Reputation: 46
Window setInterval() Method
The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds).
The setInterval() method will continue calling the function until clearInterval() is called, or the window is closed.
The ID value returned by setInterval() is used as the parameter for the clearInterval() method.
In your case you try it.
setInterval(loaddata, 5000);
Tip: 1000 ms = 1 second.
Upvotes: 3
Reputation: 175
Just create an interval before your function:
setInterval(loaddata, 300000); //300000 MS == 5 minutes
function loaddata() {
$.ajax({
url : 'load.php',
type : 'POST',
success : function (data) {
$("#table-data").html(data);
}
});
}
Upvotes: 1
Reputation: 31
You can use the setInterval function to set limit howmany time to see it.
setInterval(loaddata, 5000);
inside argument first_name is your function name and secound is time(milisecound) to useit.
Upvotes: 1