Okay, so we solved the WHY? Now, the how to fix it!
So, you still need to do the quicker version of the update. BUT, you somehow have to not do this if the
log file has not changed since the last check. In that manner, it will not keep drag’n you to the bottom
UNLESS there is a new entry. So, this is kind what is called “Error Checking” or “Validation”.
We would need to leave it at the faster speed, but add in a “Check-for-new-data”. Many ways jump into
my mind how to do this. I would say that this could get a bit tricky as you are using many different types
of connections. I mean, you are using several browser’s using the same file. Each browser would have
to keep a counter of some sort and know if the file has changed or not. Two ways jump into my mind of
how to handle this. Either use the size of the file or the timestamp of when the file was modified.
So, you can grab the file’s timestamp of the last time it was modified in this manner:
$file_time = date (“F d Y H:i:s.”, filemtime(“Your-filename”));
Then, just save this inside of a “HIDDEN” field. Since it is inside a hidden field, in your message display
code, you check the current value against the “HIDDEN” value. If the same, just skip reloading the file.
If they are not the same, load the file and reset the “HIDDEN” value. If you are only using JQUERY and
not PHP, you can just save this as a variable and not need to store it inside a “HIDDEN” field. Can’t see
your original posts of the code to remember which is used…
Did that make sense? So, in other words, the code will not load the file if the display is already up to date.
This will also save time on the server’s end as it will not waste time refreshing nothing new…
So, there you are, just try to get it working and if you can’t figure it out ask away…