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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:58:23+00:00 2026-06-10T16:58:23+00:00

I have an AJAX script which should trigger a loading image once executed and

  • 0

I have an AJAX script which should trigger a loading image once executed and then hide it once I get the result from the web-service, however the image is now showing.

My code is as below:

    <script type="text/javascript">
        function get_Code_Results() {
            document.getElementById("loader").innerHTML = "<img src=\'loading.gif\' />";
            var url = document.location;
            if (window.XMLHttpRequest) req = new XMLHttpRequest();
            else if (window.ActiveXObject) req = new ActiveXObject("Microsoft.XMLHTTP");
            req.onreadystatechange = processRequest;
    //      req.open("GET", url, true);
    //      req.send(null);
            req.open("POST",url,true);
            req.setRequestHeader("Content-type","application/x-www-form-urlencoded");
            req.send("isbns="+document.getElementById("Code").value);
            function processRequest() {
        if (req.readyState == 4 && document.getElementById("1").checked == true) {
            document.getElementById("results").value = "myfirsturl.com" + req.responseText;
        }
        else if (req.readyState == 4 && document.getElementById("2").checked == true) {
            document.getElementById("results").value = "myurl.com" + req.responseText;
        }           
    }
}
    </script>

and I have a position where I want the loader to be displayed:

    <div id="loader"><img src="loading.gif" style="display:none;" /></div>

Where do I have the mistake in my code? Some advice would be greatly appreciated!

  • 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-10T16:58:24+00:00Added an answer on June 10, 2026 at 4:58 pm
      <div id="loader"><img src="loading.gif" style="display:none;" /></div>
    

    You need to change the style="display:none;". I suggest you write the following code instead :

    <div id="loader" style="display:none;"><img src="loading.gif" /></div>
    

    Then when needed :

    $('#loader').show(); // To show the laoding icon
    $('#loader').hide(); // To hide it
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get some data from an PHP-Script via AJAX and want to have the
I have a global js file which has an ajax script. which is included
I have some JavaScript which does an ajax request from the server of which
I have this code which works. $.ajax({ type: GET, url: includes/process.php, data: captcha= +
Hi I have an ajax script which validates the users information put into textboxes.
I make an AJAX request to a PHP script which returns a number from
I'm new to JS. I have a script which should count clicks and store
I have the following script which does not work. it should be using jquery
I currently have a ajax script that dynamically builds two select boxes enabled with
At the minute I have a page with an AJAX script that searches a

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.