0
<img id="Img1" class="photoBox" src="Images/DisplayImageById.ashx?number=1&userName=<%=Page.User.Identity.Name %>"/>
         <img id="Img2" class="photoBox" src="Images/DisplayImageById.ashx?number=2&userName=<%=Page.User.Identity.Name %>"/>
         <img id="Img3" class="photoBox" src="Images/DisplayImageById.ashx?number=3&userName=<%=Page.User.Identity.Name %>"/>
         <img id="Img4" class="photoBox" src="Images/DisplayImageById.ashx?number=4&userName=<%=Page.User.Identity.Name %>"/>
         <img id="Img5" class="photoBox" src="Images/DisplayImageById.ashx?number=5&userName=<%=Page.User.Identity.Name %>"/>

I have been looking for a way to show a spinning icon until the images load without using ajax? I am researching how to load images using ajax but it wasn't going to well so I started looking for a way to do this without ajax. Is that possible?

Thank you for any help.

1 Answer 1

1

Check this. This is done using jQuery's load event, which tells when a specific element is being loaded, in your case, img

http://jsfiddle.net/blackpla9ue/uJhCt/1/

$(function(){
  $('div img').each(function(){
    var thisImage = $(this);
    thisImage.hide(0)
             .load(function(){
                $(this).show();
             });
});

Note that this would not work if you put your code inside $(document).ready(function(){ ...});

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.