Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8530141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:11:31+00:00 2026-06-11T09:11:31+00:00

My application is a MVC, using MS SQL to get the image file names.

  • 0

My application is a MVC, using MS SQL to get the image file names. I am using the following script to preload images; would like to know How I can display hourglass cursor while waiting to complete the preload.

  function preload_images() {
            var i, count = 0;
            $('#selector').css('cursor', 'wait');
            for (i = 1; i < sl; i++) {
                images[i] = new Image();

                images[i].onload = images[i].onerror = function () {
                    count++;
                    if (count == sl) {
                        $('#selector').css('cursor', 'default');
                    }
                }
                 images[i].src = impath.toString() + im.toString() + i + ".jpg";

            }
        }

It works great first time, however, when I change the file name from a dropdownlist, the hourglass does not stop even all images are load. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:11:33+00:00Added an answer on June 11, 2026 at 9:11 am

    Thanks to Musa for providing the initial solution, here is the way I got it to work, just in case someone is looking for it:

     var images = [];
            function preload_images() {
                showLoadingImage();
                $('#selector').css('cursor', 'wait');
                for (i = tochar; i < sl; i++) {
                    images[i] = new Image();
                    var name = impath.toString() + imStart.toString() + i + ext;
                    images[i].src = 'ImageHandler.ashx?img=' + name + '&window=50&level=50 &slice=0';
                    if (i == sl - 1) {
                        images[i].onload = images[i].onerror = function () {
                            $('#selector').css('cursor', 'Default');
                            hideLoadingImage(this);
                        };
                    }
                }
            }
            function showLoadingImage() {
                $('#imagediv').append('<div id="imagediv1"><img src="../Content/images/ajax-loader2.gif" alt="Loading..." /></div>');
                $('#imagediv1').show();
            }
    
            function hideLoadingImage(img) {
                $('#imagediv1').hide();
                img.onload = img.onerror = null;
           }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What are the licences required for an asp.net (MVC) web application using sql server
I'm using Linq to SQL within an ASP.NET MVC application. The model consists of
I have an ASP.Net MVC application and I'm using Forms authentication in SQL Server.
We are building an MVC 1.0 application right now and using Linq -> SQL
I am writing an ASP MVC 3 application. I am using Sql Server 2008
I have an ASP.NET MVC application which is using Linq to SQL classes placed
I have an ASP.NET MVC 3 Web Application using Linq-to-SQL for my data access
When I connect to SQL Azure from my ASP.NET MVC Application, I get the
I am currently building my first MVC 3 application, using EF Code First, SQL
I would like to get opinion on the best way to manage the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.