How to refresh part of a page automatically

2013-10-17 Thread Mike K
I have a page with a webcam image in it. The webcam uploads a new image every 60 seconds, and I use a HTML refresh to refresh the whole page every 60 seconds. It seems a bit clunky to me. It's worked just fine for several years, but I'd like to see if i can find a way to refresh only the div

Re: How to refresh part of a page automatically

2013-10-17 Thread Raymond Camden
You can use a setInterval call in JS to run every 60 seconds and reload the image. You don't need a jQuery plugin for this. On Thu, Oct 17, 2013 at 6:16 AM, Mike K afpwebwo...@gmail.com wrote: I have a page with a webcam image in it. The webcam uploads a new image every 60 seconds, and I

Re: How to refresh part of a page automatically

2013-10-17 Thread Raymond Camden
Real quick example here. It uses a date object to add a unique URL parameter to the end which should help with caching. No jQuery used, just standard HTML. The querySelector call is *kinda* modern-ish only (see caniuse.com for specifics) and could be replaced by document.getElementById. Oh - and

Re: How to refresh part of a page automatically

2013-10-17 Thread Raymond Camden
If you want to get anal, you could set a setTimeout and listen for the load event on the image. That way if it takes a bit longer to load an image one time the code will hold off on firing another request. (Probably not an issue though if you are waiting 60 seconds.) On Thu, Oct 17, 2013 at

Re: How to refresh part of a page automatically

2013-10-17 Thread Mike K
Ray, thanks for this. I can see you get your kicks writing bits of code like this dont you. You've gone wy past answering my question as you usually do, and I'm most grateful. I have a suspicion your idea of a relaxing evening on your vacation is a coding problem and a laptop, where

Re: How to refresh part of a page automatically

2013-10-17 Thread Raymond Camden
On Thu, Oct 17, 2013 at 8:40 PM, Mike K afpwebwo...@gmail.com wrote: Ray, thanks for this. I can see you get your kicks writing bits of code like this dont you. You've gone wy past answering my question as you usually do, and I'm most grateful. I have a suspicion your idea of a