Skip to content

Pseudo “Push” on WebPage by Sending Heartbeat requests

$(document).ready(function (){

  // tick frequency
  var Hz = 2;

  function tick() {
    $.post('/quidditch/heartbeat.api')
      .done(function (data) { console.log(data); })
      .fail(function () { alert('Disconnected'); });
  }

  function gameTicker() {
    setTimeout(gameTicker, 1000/Hz);
    tick();
  }

  gameTicker();

});
Published inUncategorized

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *