Forum Moderators: open

Message Too Old, No Replies

ajax and images

         

bleak26

8:38 am on Jun 16, 2006 (gmt 0)

10+ Year Member



Hi i have a simple question which i hope yuo can help with.

Is it possible to load a new image without reloading a page using ajax?

jshanman

12:43 pm on Jun 16, 2006 (gmt 0)

10+ Year Member



var image = document.createElement("img");
image.alt = "some image";
image.height = "50";
image.width = "50";
image.src = "path/to/image.jpg";

document.appendChild(image);

OR

document.getElementById("someDiv").innerHTML = "<img src='path/to/image.jpg' alt='some image' width='50' height='50'>";

Either way works.
- JS

adni18

4:58 am on Jun 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



or add?randomnumberhere to the end of the url. (of course, maybe not a random number but a number from a counter)

adni18

4:58 am on Jun 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



or add?randomnumberhere to the end of the url. (of course, maybe not a random number but a number from a counter)