I have an <img src="..." />
tag with a default src
set. I'd like to have jQuery make an ajax request to get another image and when this new image is fully loaded, set the src of the <img ... />
tag so there's no flicker. I'd prefer not to do any of the preloaders like new Image().src="foo"
etc. I'd really like the iamges to load on an ajax request. Any ideas?
Asked
Active
Viewed 9,470 times
5

Sune S.-T.
- 235
- 2
- 15

Mark Ursino
- 31,209
- 11
- 51
- 83
-
You could swap the ```
``` element altogether instead of changing the ```src``` attr. Check this http://stackoverflow.com/questions/4285042/asychronously-load-images-with-jquery – dekkard Mar 23 '16 at 10:50
1 Answers
-1
You cannot load "a part" of a image onto the webpage so you cannot load it incrementally.
The image can be loaded by using a CSS class point to an image or using Image object of Javascript.
Since CSS cannot notify the page whether the image fully load so the approach new Images().src = "foo" is the best it can do.
Attach an event to it and "decorate" it to reduce flicker with FX effect: fade in, ....

thethanghn
- 319
- 2
- 5
- 21