First off, thanks to all of the great answers that I have seen that have helped me out with past projects.
Here is what I'm trying to do. I am putting together a home automation system and one of the things I would like to do is send a request to my web server and have it give me a status in real time.
99% of this, I have working. What I am needing (wanting) to do now is have a simple page check the status of a file on my webserver and have it change an image accordingly in real time.
The content of the file will be one of the following words ONLY:
On, Off, Open or Closed.
I can use a page refresh and my back-end ASP will do the work, but I am wanting something a little more elegant than page flicker on a refresh. So, I figured if there was some way to check the contents of the file in JavaScript, then I can just do something like the following using the contents of the file in the variable fileContents
:
document.GetElementById('image').src = 'MyServer.address/GFX/' + fileContents + '.png'
This way when the file gets changed on my server, the image displayed on the page changes in (near) real time without flicker.
Please help me find the missing link in this scenario.
I would like to keep the resulting page as compact as possible. Here is a sample of the page that my ASP generates:
http://ssbbs.dyndns.org/panic/isy.asp?A=3D30711&T=S
It shows a green circle if the device I'm polling is on and a blue circle if the device is off.
The file I will read as an example is: