0

I am trying to append a timestamp to the query string to force a refresh of the images or any other way to force a refresh. It does not seem to refresh my images by setting ajaxSetup cache to false.

How would I do it otherwise?

The jquery for this

<script>
    $(document).ready(function() {
        $.ajaxSetup({'cache':false});
        $('#right').load('score.html');
     alert('loaded');
    setInterval(function() {
        $.ajaxSetup({'cache':false});
        $('#right').load('score.html');
    }, 10000);
    });
</script>

The score.html

<img class="small" src="VTVFile1.jpg" alt="Image not found" onError="this.onerror=null;this.src='demo.jpg';" />
<img class="small" src="VTVFile2.jpg" alt="Image not found" onError="this.onerror=null;this.src='demo.jpg';" />

<img class="small" src="VTVFile3.jpg" alt="Image not found" onError="this.onerror=null;this.src='demo.jpg';" />
<img class="small" src="VTVFile4.jpg" alt="Image not found" onError="this.onerror=null;this.src='demo.jpg';" />
user2130951
  • 2,601
  • 4
  • 31
  • 58

2 Answers2

0

You can use like this.

<img class="small" src="VTVFile1.jpg" 
alt="Image not found" 
onError="this.onerror=null;this.src='demo.jpg?'+new Date().getTime();" />
Vijay Maheriya
  • 1,617
  • 16
  • 21
0

Why don't use Math.random() function

$('#right').load('score.html?r='+Math.random());