Ok, here's the scenario. I'm wanting to have a page open on a client for a long, long time. Say... one week or one month even. I've got Ajax sending requests continuously, sending a new request whenever data is received or whenever the initial request times out.
and on the server side, the server only sends data when something changes (in this case, the internal temperature). The PHP code is:
//First, the last known temperature is fetched from a DB, and put into $oldTemp
$i = 1;
while ($i <= 10){
$temp = getTemp();
if ($oldTemp == $temp){
sleep(5);
$i++;
} else {
$con->query("UPDATE deviceStatus SET statusValue=$temp WHERE id=1");
$i = 15;
}
}
echo $temp;
As you can see, the server will hold the connection open until 50 seconds, then send the current temperature. If the temp changes during the 50 seconds though, it will send the update almost immediately.
I'm having that Ajax function run over and over and over.
Seems like it ran for a few hours fine overnight... probably about 12 hours if I had to guess... and then stopped updating. The jQuery AJAX call stopped working, as the script never spawned the Ajax PHP call which updates the database, because I saw the database had old data. That means it isn't an issue of the new data not getting added to the DOM, but rather the Ajax call itself was never kicked off.
Is there a maximum number of times an Ajax request will get sent, or a period of time after which the page just stops sending that data? Possibly I just need to set a meta refresh value for, say, 8 hours?
Host is an Ubuntu client running Chromium, if that matters.
I am working on a little mobile site for my own home-built home automation system. Essentially I'd like to have a bunch of listviews that, when tapped, send an Ajax request to a server and does not load in any data or create a new page. This is so I can send TV remote control commands, turns lights on and off, set AC, etc.
1) Is there a way to prevent the pages from loading into DOM, as I am simply sending AJAX and don't care about the response? If not, can I delete the pages from the DOM? If I use this as a remote control, I could end up with thousands of pages over the course of a day or three.
2) Any way to keep the listview item from staying selected after a click? I'd like it to briefly show as blue (selected), then go back to the normal color.