Flashing ajax requests

I have a basic ajax request and now it is set to 3 seconds. will be higher, but I want to fix the problem that happens every time a request occurs. for some reason, every image (stored in the database - not so many thumbnails), they all blink.

Is there a way to blink images in a get request?

$(document).ready(function(){ var ajaxDelay = 3000; setInterval(function(){ $('#timedContainer').load('jquery_timed.php'); }, ajaxDelay); }); 
+4
source share
2 answers

As far as I know, you need to preload / cache images before displaying them to avoid this flash. Here is another answer on how to do this.

+2
source

You can use two images, the first option for an existing img that does not take a lot of time to load, and the second real img. Real img can be hidden or their size can be 1 * 1px.

 <img id="IMG1" src="Some_light_IMG" > <img id="IMG2"src="heavy_IMG" style="display:none;" onLoad="JavaScript:$('#IMG1').hide(); $('#IMG2').show()"> 
0
source

Source: https://habr.com/ru/post/1435805/


All Articles