![]() |
Using AJAX and PHP to check filemtime($filename)
Hi all,
I have a flat file that I would like to have updated in my browser if someone on another computer updates it. What I have done so far is use PHP to tell me when the last update happened. So what I was thinking I should do is use AJAX to run in the bg every 10 seconds or so and check if that filemtime() has changed. IF it has, update the div with the current text file info. Any thoughts on how to use AJAX as a timer in this fashion? or do I need to do something else? Thanks! |
Do you know how to use AJAX? If so, you could simply introduce
setInterval into the equation, and trigger the AJAX every 10 seconds.javascript Code:
|
I understand it, but don't know how to implement it always... is this what you mean AND what ready state would I use to run in the bg?:
Code:
<script type="text/javascript"> |
You'll need to make a call to
ajaxFunction inside the setInterval function. You could use Prototype, and then you have Ajax.PeriodicalUpdater. |
GIANT FUDGE INCOMING!
Quickly hacked this together (yes its probably over engineered, but I got carried away), seems to work! javascript Code:
|
| All times are GMT. The time now is 07:37 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0