Ajax refresh image

Ajax refresh image

I'm using the database image widget in a Screen. In this Screen I have a link to a popup where I can upload a new image. The process of recording, notifying the widget and refreshing the image is working fine.

But the browser caches the image and I have to mannually refresh it (Ctrl+F5) to get the new image shown.

Am I doing something wrong?

I'm going to answer this, based what you are saying. refreshing should be working normally.
but if the browser is indeed caching the image, it's a simple matter of adding a timestamp/dynamic in the img-url.
thus something like image.jpg?ts=2362663
this will "force" the browser to notice the url has changes. It keeps caching the image,
but because the url has been changed after the refresh, it goes looking for the new image anyways.

J. ,

Just a quick question. Using the outsystems standard Image widget and it setting as a database image, I'm not being able to add to the image filename atribute something like "?"+IntegerToText(Minute(CurrDateTime()))+IntegerToText(Second(CurrDateTime())) because the ? character will be escaped to %3f.

Like João Melo asked, Am I doing something wrong?

Using a debugger and manually changing the %3f to ?, the ajax refresh works like a charm showing the new file uploaded via popup_upload.

Thanks in advance!

I was also having the same problem with joão with the image source is from database. I have a rotate feature in which after the rotate action I invoke ajax refresh but it doesn't refresh the image. I need to press F5 to refresh the image and see the effect.


You can try changing the filename of the image when saving it to the Database by appending some random chars to the end. I used Photo.Filename + GeneratePassword(10,True) which causes the browser to fetch the image every time you change it since the name changed, thus causing it to refresh.

Best regards,