$(document).ready(function(){ lasteventid = 3887306; setTimeout("getSiteEvents()",10000); }); function getSiteEvents() { //this.lasteventid = lasteventid; var lasteventiddata = "eventid=" + lasteventid; $.ajax({ url: 'http://jordanbalagot.com/siteevents.php', type: 'GET', dataType: 'json', data: lasteventiddata, timeout: 1000, error: function(){ //alert('could not get json'); }, success: function(json){ for( var i = 0; i < json.length; i++ ) { $.jGrowl(json[i].message, { life: 2000 }); if(json[i].eventid > lasteventid) { lasteventid = json[i].eventid; //alert("setting lasteventid" + lasteventid); } } } }); //alert(lasteventid); setTimeout("getSiteEvents()",10000); }