php - Html/Js live update page -


i programming website church hockey league, , trying make page live updates. trying setinterval() signal php update time.txt live page can draw time from. update.html has time on it, page sends time php doc function writes time time.txt, live.html gets time every 5 secs setinterval(). in 5 secs live.html keeps own time, needs check every 5 pauses or time changes.

the problem this: server cant handle updating time.txt every 2.5 seconds need simpler method doesn't require me update time.txt every 2.5, live.html still can time, pauses, , time changes.

any please.

here update.html

$('#play').click(function(){     if(pause == true){         $('#play').attr('src',"mup/pause.jpg");         $.get("mup/postt.php", {text: "11"});         pause = false;     } else {         $('#play').attr('src',"mup/play.jpg");         $.get("mup/postt.php", {text: "09"});         pause = true;     } }); function updatet(){     if(sec < 10){         if(min < 10){             var clientmsg = "0" + min + ":0" + sec;         } else {             var clientmsg = min + ":0" + sec;         }     } else {         if(min < 10){             var clientmsg = "0" + min + ":" + sec;         } else {             var clientmsg = min + ":" + sec;         }     }      $.get("mup/postt.php", {text: clientmsg}); } setinterval (timer, 1000); setinterval (updatet, 3000); 

all variables defined @ beginning of doc.

here live.html

function timer() {     if(stop == true){         $("#time").html("<h5>game stopped</h5>");      } else {         sec = sec-1;         if(sec <= -1){             sec = 59;             min = min-1;             if(min <= -1){                 sec=0;                 min=0;             }         }         $("#time").html("\<h2\>"+min+":"+sec+"\</h2\>");     } } loadlog() {     $.ajax({         url: "mup/time.txt",         cache: false,         success: function(html){             var min = html.charat(0).concat(html.charat(1));             var sec = html.charat(3).concat(html.charat(4));             var time = min + ":" + sec;             if(time == timel){                 stop = true;             } else {                 stop = false;             }             timel = time;         },     }); } setinterval (loadlog, 5000); setinterval (timer, 1000);  

and @ beginning of doc variable defined timel , time being different. post.php puts sent stuff onto doc, time.txt "06:08" or whatever.aa


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -