javascript - ASP.NET MVC - How do I load an image asynchronously? -


On the home page of my site, I want to display a lot of products in which the images are too large Taking it for so long that it's really time is up and the page fails to display!

In general MVC or just ASP.NET, how can I load an image asynchronous? Basically what I want to do, displays product details and just displays a small loading image eg . Unless the image loads.

I think this requires some JavaScript / jQuery ...

  & lt; Img src = "ajax-loader.gif" onload = "this.onload = null; this.src = 'bigimage.png';" / "  

Or if you prefer randomly:

  & lt; Img src = "ajax-loader.gif" id = "myimg" />  

and then:

  $ (function () {$ ('# myimg'). Load (function () {$ (this). ( 'Load'); this.src = 'bigimage.png';});});  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -