1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Update image on page?

Discussion in 'PHP' started by rickbkis, Aug 25, 2005.

  1. #1
    I need to update an image on a page (without reloading the page.)

    I can do it with an IFrame, but that's kinda awkward.

    xajax seems to be a possibility - only issue is it appears to use the xmlhttp transport - that suggests I'd have to encode/decode the image to get it into xml - performance issues there, I would think.

    xajax is supposed to support other mime types, but, since it uses the xmlhttpc transport, will it send an image mime correctly?

    Or, is there another way to do this?

    Anyway, I'm going to give it a shot - just wondering if anyone might have done it already.

    rickb
     
    rickbkis, Aug 25, 2005 IP
  2. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can change the value of an image's src attribute using JavaScript, and the new image is automatically loaded.
    var img = document.getElementById('img1');
    img.src='http://www.domain.com/images/image2.gif';
    Code (markup):
    Don't know what the effect would be if the images were different sizes though, that might screw up page layout.
     
    johnt, Aug 25, 2005 IP
  3. rickbkis

    rickbkis Peon

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Right.

    Just realized that (although my variant is to invoke a php script to get the image - keeps proprietary images out of webspace. And that works just fine.)

    So, I guess I'll suspend my xajax investigations for the moment.

    thanx,
    rickb
     
    rickbkis, Aug 25, 2005 IP