I have a webpage which takes some user input and uses it to update an image by running a shell script through PHP. This image is then displayed to the user without refreshing the page they are on (using an ajax request). The general gist is:
- User makes selection on web page
- Web page sends ajax request to server
- PHP (laravel) catches the ajax request and runs a shell script to update an image
- PHP returns the ajax response and says whether the image was updated or not
- If the image was updated, javascript refreshes the image for the user using the following code:
$("#back_thumbdiv_med").find("> img").attr("src", url + "?" + new Date().getTime());
The problem is that the images don't load properly. Here is an example of a loaded image.
It's interesting to note that the part of the image that is showing is actually part of the old image not the new image. What could be causing this? How can I fix it? Could this be related to my site being run on a VM through vagrant?
Also, if the user navigates away from the page and back, the image will obviously return to the old version because it's cached. I'd like the images to be cached but to be able to force a refresh after the ajax request returns. What