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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:47:38+00:00 2026-06-01T13:47:38+00:00

I would like to display an ajax loader icon when user try to submit

  • 0

I would like to display an ajax loader icon when user try to submit a form, and block the content of the page (Fade in).

I have this code, but it works wrongly, it display the loader icon before submitting the form and hide it after submitting the form.

<script type="text/javascript">
function ajaxFunction() {
    var xmlHttp;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            document.getElementById("content").innerHTML = xmlHttp.responseText;
        }
    }
    xmlHttp.open("GET", "?action=sms&pageaction=Send SMS", true);
    xmlHttp.send(null);
}​
</Script>

And I have DIV :

<!---progress-->

<div id="content" > 
  <br/>
  <br/>
  <br/>
  <h1>Loading ... Please wait </h1>
  <br/>
  <br/>
  <img src="image//loading.gif" />
    </div>

<!---progress-->

And the submit button is calling the ajaxFunction()

<input type="submit" name="pageaction"  class="send_sms" value="Send SMS" onclick="ajaxFunction()" />

Anybody please help me in correcting my code to make it work as follow:

  1. display a transparent background to block the page while submitting the form.
  2. display a loading icon.
  3. Hide the transparent background and hide the loading icon.

Thanks for all

  • 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-01T13:47:39+00:00Added an answer on June 1, 2026 at 1:47 pm

    Set your content to hide. You can do that simply:

    <div id="content" style="display:none;">
      ...
    </div>
    

    Put it visible before sending the AJAX request.

    document.getElementById("content").style.display = "block";​​​​​​
    xmlHttp.send(null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an @Ajax.ActionLink which for which I would like display a confirmation dialog
so I have a PHP iframe (ajax) file uploader. I would like to display
We would like to display text and images of an web page in higher
I would like to display a catergory page as my homepage rather than a
I would like to display a JSON response (from an ajax call) in a
I have following JSON string returned to a page. {firstName:Bob,lastName:Gates,department:Tech} I would like to
I would like to use Fancybox to display a registration form within an iFrame.
i would like to display images on my website that are stored on a
I would like to display a svg file inside a eclipse view. a) It
I would like to display a list of records from my database, then for

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.