-
-
Save imzjy/5f3ff1f08a9df7fe4a77b8390fecad8b to your computer and use it in GitHub Desktop.
polling jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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