Skip to content

Instantly share code, notes, and snippets.

@dbellettini
Created July 22, 2011 12:47
Show Gist options
  • Save dbellettini/1099383 to your computer and use it in GitHub Desktop.
Save dbellettini/1099383 to your computer and use it in GitHub Desktop.
Javascript jQuery JSON polling
function Poller (url, callback) {
this.url = url;
this.callback = callback;
this.start = function(interval) {
var url = this.url;
var callback = this.callback;
var fn = function() {
jQuery.getJSON(url, callback);
};
fn();
this.interval = self.setInterval(fn, interval);
};
this.stop = function() {
if (this.interval) {
self.clearInterval(this.interval);
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment