Skip to content

Instantly share code, notes, and snippets.

@bit4bit
Created January 23, 2015 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bit4bit/44bdb1f0a35894569568 to your computer and use it in GitHub Desktop.
Save bit4bit/44bdb1f0a35894569568 to your computer and use it in GitHub Desktop.
polling jquery
function pollUrl(url, renderer) {
return function(render){
if(render == undefined) { render = renderer; }
$.getJSON(url, function(data){
render(data);
}).always(function(){
setTimeout(pollUrl(url, render), 5000);
});
};
}
/*now poll and render*/
pollUrl("localhost/stats")(function(data){
$("#view").html(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment