Link to home
Start Free TrialLog in
Avatar of nysurf1
nysurf1

asked on

ajax question (forcing image refresh)

I have a function that calls a php page to rotate an image
********
                 var myurl = "rotate.php?img="+document.getElementById('r_img').value+"&r_dir="+document.getElementById('r_dir').value;
         http.open("get", myurl, true);
         http.onreadystatechange = rotateIt;
*********
That php page overwrites the image sent to it , rotates it 90 degrees and returns the same path of the image (after its been rotated and saved), when i get this image i refresh the src of the image
************
if (http.readyState == 4) {
       document.getElementById(document.getElementById('id_img').value).src=http.responseText;

  }
*************
What happens is that on the page the image shown is from the cach of the page (doesn't change) , if i delete the temporary files and refresh the page i see the new rotated image but i want it to be done without refreshing the page at all .
I guess one option is to rename the image when i rotate it , that could work but its a little complecated for me do do it now because all the images are stored in a database with some logic to their names so im hoping to find a simple solution that refreshes the cach of the image
Thanks!!

ASKER CERTIFIED SOLUTION
Avatar of mouatts
mouatts

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nysurf1
nysurf1

ASKER

Can you send me the code for the no-cache header , can i just put it in the header of the page where the images are loaded too?
thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nysurf1

ASKER

Thanks ,
In the end i went with renaming the photo since the no-cache option is quite costly (its on a page with many images)