jquery - showing loading image still shows "browser loading image" icon -


shows an Ajax loading image until I load all Asennc my images that is running this code and download the real image .

  $ ('img.loadable-image'). CSS ('Background', 'Transparent URL (/images/ajax-loader1.gif) No-Dual Center Center') $ ('img. Loadable-image'). Load (function () {$ (this) .css ('background', '');});  

This works shows my Ajax loading icon until the images download, but the background will also show

Here is my original image html: < / P>

  & lt; Img class = "loadable-image" src = "mysite.com/validimage.jpg" range = "0" height = "50" width = "50" & gt;  

Here I get it is a screenshot:

As you can see on the left, you see a little Ajax loader But also

any suggestions?

, which defines that and Code> src attribute.

Unavailable category src & lt; Img & gt; Set Tag feature if it's a valid image is not set on the URL, then you "Broken Image" frame will set the source rather than the background (or the transparent image) or < Img> instead of element Change to Element. / P>

Not valid, No src attribute == "broken image" icon:

  & lt; Img alt = "style =" width: 50px; height: 50px; background-image: url (bg. Gif) "/>   attribute: 

  & lt; Img alt = "src =" transparent.gif "style =  

valid =" width: 50px; height: 50px; background-image: url (bg. Gif) "/ & Gt;


After your edit, I can see that you are doing it correctly, the problem is that it takes a long time to download the image. In that case, you have a few options:

  • If you have control over images, (keep GIF / PNG as interlace, JPEG as progressive).
  • If you do not have control over the images, wrap the hidden IMG in the spin, apply the background image to the span element and show the image when the load event is in the fire.

Ex:

  & lt; Span class = "loadable-image-container" & gt; & Lt; Img class = "loadable-image" src = "mysite.com/validimage.jpg" range = "0" height = "50" width = "50" & gt; & Lt; / Span & gt;  

jQuery, something like this:

  $ ('img.loadable-image-container'). CSS ('background', 'transparent url (images / ajax-loader 1 gif) no-center center'). children (). CSS ('visibility', 'hidden'); $ ('Img.loadable-image'). Load (function () {$ (this). CSS ('Visibility', 'visible') .Parent (.css ('background', '');});  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -