Jump to content
  • Advertisement
Sign in to follow this  
Ilici

Changing an image with AJAX

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

On a website I have an image and some buttons. The image is generated by a server-side script which I call through an XMLHttpRequest both when the page is loaded ("onload") and when the buttons are pressed. The script regenerates the image and returns it's name and path (which remain the same for multiple calls). When I first create the page I just write an "img src="picture.jpg"" tag and the image is loaded when the script executes for the first time.
function handleHttpResponse()
{
   if (http.readyState == 4)
   {
      document.images[2].src = http.responseText;
     }
}
I use that code to change the image but the HTML code of the page doesn't change. How can I get my image to be changed and refreshed when I press the buttons? Another thing: how can I use "hover" CSS for "td" table cells? (i want the whole cell to change color on hover, a cell contains an image)

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!