Results 1 to 2 of 2

Thread: Ajax Dynamic Content - images

  1. #1
    Join Date
    Apr 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Ajax Dynamic Content - images

    http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    Is it possible to call up images (gif,jpg) directly into the container div using this script? I've tried simply changing the request page like so
    <a href="javascript:ajaxpage('a.gif', 'contentarea')">
    and it gives an error of
    GIF89a??

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    You shouldn't use Ajax to dynamically call an image. Simply change the src property of an image to the one you wish to include. For example:

    Code:
    <img id="myimage" src="then.gif" />
    
    <script type="text/javascript">
    function changeimg(id, url){
    document.getElementById(id).setAttribute("src", url)
    }
    
    changeimg("myimage", "http://google.com/logo.gif")
    </script>
    When changeimg() is run above, it changes the image from then.gif to logo.gif.

Bookmarks

Posting Permissions

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