i'm trying changing dinamically the src path of a img tag
i have:
<img src="img1.jpg">
Then i upload new photo by iframe and new photo takes the same name (img1.jpg) then by ajax i refresh the src path (which is the same but photo is changed)
The problem is that i use same 开发者_Go百科file name, img doesn't change in browser, guessing cause of browser cache...
Is there any jquery,html or php solution on this?
thanks
You could try appending a random query string to the end... img src="img1.jpg?random_string"
You could return the image as a base64 string in the ajax response, and append the data to the img element.
<img src="data:image/jpeg;base64,[STRING GOES HERE]" alt=""/>
This way you will save another request. However, the base64-encoding means a few more bytes are transferred.
Its been cache issue.To resolve this issue use Math.random() as query param
<img src="url_goes_here?Math.random()" />
精彩评论