IE8 cache ajaxSubmit
I am using the following function to do a image 开发者_StackOverflow中文版upload/display
The Target is the div where I am updating the content that is returned from the form function. I wanted ajax so I don't have to reload the whole page just to upload and see previews of the image.
I upload a image, display it into the preview, I crop it, and do another function that displays it in a new target (not shown),
The problem is in IE 8 it seems to cache all ajax calls, even though I am setting it not to, the only way to get it to show is a hard refresh. Is there a way to force it to not cache? This works fine in all other browsers of course.
$("#profile-photo").submit(function() {
var myOptions = {
target: '#preview-target',
beforeSubmit: showRequest,
success: showResponse,
clearForm: true,
resetForm:true,
cache:false
};
$(this).ajaxSubmit(myOptions);
return false;
});
I doubt it's caching the submit, more likely it's caching the image url. In your response, are you just sending back the url for the new image? If so, try appending a query string:
<img src="/my/path/to/my/image.jpg?q=12345" />
That should force all browsers to re-load the image from the server.
If this concerns a GET
request, then this is true. If you don't have any option to change it to POST
, then the best way is to dynamically append an extra query parameter with a timestamp to the URL on every request. In Javascript you could use new Date().getTime()
for this.
精彩评论