简体   繁体   中英

jQuery Datatable cache problems with images

I'm using the jQuery Datatables for showing a list of logged in people. It contains for each person a cell with the picture, login date/time, name, information. A user can update his profile picture which is shown in one of the cells. The Datatable refreshes every two seconds using the this:

    ajax: 'scripts/loggedinlist.php',

setInterval(function(){
   mytable.fnReloadAjax('scripts/loggedinlist.php');
 }, 2000);

When the user updates his picture, it keeps showing up the old one. I have to clear the browser cache to see the new one.

I tried adding the

cache: false

option and i disabled the google chromes browser caching - still doesn't work.

Does anyone know how to fix this issue?

Thanks!

You can make URL with img.png?+new Date().getTime() or as you have lastupdated field img.png?+lastupdated

that will get solve your problem with image cache

You can try something like this.

 setInterval(function(){
   $("#Your_Table_Id").dataTable().fnDraw();
 }, 2000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM