...

View Full Version : Beginner's AJAX request - refreshing images



omarsmith
08-28-2010, 05:54 PM
hey,

I have a web page which loads four images from a server - the images are captures from a webcam feed which are updated every 5 minutes via FTP (named "image0.jpg","image1.jpg","image2.jpg" and "image3.jpg").
the images are inside a table and are already within <DIV> tags.

Currently I have a simple META refresh which reloads the whole page every two minutes, as I know precisely nill about AJAX - but clearly this is very inefficient and puts unnecessary load on the server.

What I am posting to ask is, from the very top, with the only assumed knowledge that I know how to write HTML and change file permissions on the server - how do I use AJAX to reload these images every minute?

Hopefully this is an easy ask of anyone who knows something about AJAX - thanks! :)

A1ien51
08-28-2010, 11:18 PM
What you are doing is not causing massive strain on the server. You are not talking about a page that is dealing with tons of backend resources.

Ajax does not require changes on the server.

BUT in your case Ajax is not needed to update images.

To update an image you just to update the src, to make sure you do not get it from the cache you need to add a useless querystring.


window.setTimeout(
function(){
document.getElementById("ImageId").src = "image1.jpg?ts=" + new Date().getTime();
}, 1000);


Eric



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum