Reputation: 223
I am developing a web application. where data need to be updated when ever there are changes.
Currently I am putting an interval[5 sec] for fetching data from server[getting data with ajax requests].
But here problem is unnecessary calls are going even though there is no update in the server data.
Can any one tell me best solution for this.
Below is sample code What I am doing:
setInterval(function() {
$.ajax({
"url": validURL,
"dataType": "json",
"contentType": "text/plain",
"method": "GET"/"POST"
}).done(function() {
//After getting the response here updating the Ui elements here.
});
}, 5000);
Upvotes: 0
Views: 23