3nath
3nath

Reputation: 223

need a solution ajax push mechanism

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

Answers (1)

Justin
Justin

Reputation: 686

You can try jQuery Tiny Pub/Sub or Q

Upvotes: 0

Related Questions