I have a an asp.net-mvc site. On one of the pages, I have an image, I use jcrop to allow users to crop the image. When this click submit, I crop the image on the server side and then reload the page. The issue is that the image looks the same as before . . if i hit F5 and refresh the page then the updated image shows up..
Is there anyway to avoid having to force a F5 refresh in this case?
You should be able to refresh the image using JQuery.
Basically you need to set the src of the image again when the user submits the cropped image.
Another problem you may encounter if the image has the same name is browser caching.
This has been answered here before: How to reload/refresh an element(image) in jQuery
Expanding on one of the other answers
if you have the photo on your server, or accessible then you can stat the file itself and use the modified time in the image source:
This gives the best of both worlds as it will use browser caching normally but will force a re-read if the image file is changed (e.g. through re-upload)
Some trick is to change the name of the image. You can also change the HTTP header to make sure to browser does not cache the image.
Setting optimum http caching headers and server params in ASP.Net MVC and IIS 7.5
This is a trick, but it works.
Put a variable and random number in the image url. Something like:
Maybe there's a better way, but it works for me.
I would recommend posting the coordinates of the crop to a php script, cropping in php, giving it a new name then setting the SRC attribute to the url of the new image.
Something like but needs tidying:
jcrop page:
saveimage.php