Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2010
    Thanked 0 Times in 0 Posts

    Question Beginner's AJAX request - refreshing images


    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!

  2. #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Between DC and Baltimore In a Cave
    Thanked 94 Times in 88 Posts
    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.

            document.getElementById("ImageId").src = "image1.jpg?ts=" + new Date().getTime();
        }, 1000);
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts