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 6604101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:06:30+00:00 2026-05-25T19:06:30+00:00

i am going to call my server side method by jquery and my server

  • 0

i am going to call my server side method by jquery and my server side method will just give a html like <img src='pop.gif' />

after getting the image url from server side function i will just push the html into my div but i want the when image will be loading at client side then i want to show a busy image. so i plan to write the code like below

first code call server side method

$.ajax({
  url: 'image-map.aspx',
  data: {}, // the image url links up in our fake database
  dataType: 'html',
  success: function (html) {
    // because we're inside of the success function, we must refer
    // to the image as 'img' (defined originally), rather than 'this'

   var img = $(html);
   $(img).load(function() {
      //alert('Image Loaded');
   });
   $('#myidv').append(img);

  }
});

so i just need to know my code is ok. does it work and how to show spinner image till the image download at client side?

  • 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-05-25T19:06:31+00:00Added an answer on May 25, 2026 at 7:06 pm

    First of all, you should put the img appending inside the onload function like this:

    $(img).load(function() {
        $('#mydiv').append(img);
    });
    

    This way the image will only be inserted after it’s done loading.

    For the loading part, there are many approaches, but one way is to put a loading image in the destination element (#mydiv), and remove that image at the same time when appending the new image. Something like this:

    $.ajax({
        beforeSend: function() {
            $('#mydiv').append($(<img src="loading.gif" class="loading" />);
        },
        success: function(html) {
            var img = $(html);
            $(img).load(function() {
                $('#mydiv .loading').remove();
                $('#mydiv').append(img);
            });
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just going over the asio chat server example . My question is
I'm looking for an easy way to call a bean's method that will take
My server side contains WCF4 REST services and I'm going to add RIA services
My web app is going to call a webservice. I'm looking for best practices
I'm working on designing the kernel (which I'm going to actually call the core
So i need to run a jdbc call that is going against a sql
I'm doing some simple client side validation with jQuery. var passedValidation = new Boolean(true);
I'm using HTTP POST to call a cgi script on a web server and
I'm not an expert in Server-side programming nor Java-EE, and I've been looking how
Before I start explaining the code I will first give my use case so

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.