Skip to content

Instantly share code, notes, and snippets.

@putzflorian
Created June 12, 2014 12:31
Show Gist options
  • Select an option

  • Save putzflorian/105148efd67a070aed61 to your computer and use it in GitHub Desktop.

Select an option

Save putzflorian/105148efd67a070aed61 to your computer and use it in GitHub Desktop.
Ajax polling
if(typeof(Storage) !== "undefined") {
var d = new Date();
var n = Math.round(d.getTime() /1000);
if (sessionStorage.toralarmvisit) {
} else {
sessionStorage.toralarmvisit = n;
}
$.ajax({
type: "GET",
url: urlPrefix + "/wm2014/toralarm",
datatype: 'json',
data: { naked: true, toralarmvisit: sessionStorage.toralarmvisit }
}).done(function( msg ) {
msg = JSON.parse(msg);
if(msg.status){
$('#toralarminfo').html(msg.data);
$('#toralarm').fadeIn();
sessionStorage.toralarmvisit = msg.tmstamp;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment