Smartupdater: A JQuery periodical updating mechanism

I often need to implement some kind of periodical updating functionality from client to server and vice versa. Aka a classic polling mechanism. Smartupdater is a jQuery plugin which simplifies the process of sending regular requests to a server (polling) and handling the responses. I have found it very useful, and easy to work with. It can be started or stopped on any event and the interval of the polling periods can be redefined as well as controlled remotely.

A simple example would be how to display the remote time on a server with a polling interval of 5 seconds. Note that the remote script is returning a JSON format like this: “{“servertime”:”hh:mm:ss”}”

$("#example1").smartupdater({
  url : 'gettime_json.php',
  dataType:'json',
  minTimeout: 5000 // 5 seconds
  }, function (data) {
    $("#example1").html(data.servertime);
  }
);

The returned results can then be displayed in a div tag…

    
      Time on server: hh:mm:ss

Download link: https://code.google.com/p/smartupdater/