I have some code that displays the number of people viewing a specific twitch.tv stream. It loads the number once and displays it. If someone wants an update on the number of viewers, then they have to refresh the page. Is there a way to refresh the number every few seconds, so that people don't have to refresh the page? the code is below (its the div id=viewers that i want to update)
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" charset="utf-8"></script></head></html>
<script type="text/javascript" >
var channelName = "crossgamechat";
function showViewers(a){
alert(a.viewers_count);
}
$.getJSON("http://api.justin.tv/api/stream/summary.json?channel="+ channelName + "&jsonp=?", function(a){document.getElementById("viewers").innerHTML += a.viewers_count;});
;
</script>
<div class="clear"></div>
<div style="width: 100px;">
<div id="viewers" style="float: left"></div>
<div id="blank" style="float: left; width: 5px;"> </div>
<div id="divtext" style="float: left;">Viewers</div>
<br style="clear: left;"/>
</div>
</head></html>