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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:58:15+00:00 2026-05-23T11:58:15+00:00

Goal : When click a link on my navigation will show spinning image until

  • 0

Goal : When click a link on my navigation will show spinning image until script fully loaded.

function ahah(url, target) {
  document.getElementById(target).innerHTML = '<img src="loading.gif" />';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function ahahDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

function load(name, div) {
    ahah(name,div);
    return false;
}

On Link

<a href="wrapper.html" onclick="load('file1.html','content');return false;">File 1</a>
<a href="wrapper.html" onclick="load('file2.html','content');return false;">File 2</a>

On content wrapper

<div id="content"></div>

Let me know simple way to do this on jquery.

  • 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-23T11:58:16+00:00Added an answer on May 23, 2026 at 11:58 am

    Assuming each <a href="wrapper.html"> element corresponds sequentially to a file-n.html, you could do this:

    $(function() {
        var content = $('#content');
    
        $('a[href="wrapper.html"]').each(function( i ) {
            var name = "file" + (i + 1) + '.html';
    
            $(this).click(function( e ) {
                e.preventDefault();
                content.html( '<img src="loading.gif" />' );
                $.ajax({
                    url: name,
                    dataType: 'html',
                    success: function( data ) {
                        content.html( data );
                    }, 
                    error: function(xhr, status, error) {
                        content.html( "Error:\n" + status + "\n" + error;
                    }
                });
            });
        });
    });
    

    Of course, don’t forget to include the jQuery library first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

GOAL 1: When click the button, if there isn't any radiobutton checked, it will
My end goal is to be able to send: $('[data-track]').live('click', function () { mpmetrics.track(Share,
My goal is to let the user click on a specific location on a
Please take a look at this link , then click on the bottom in
Ok, I am working on a project where an end user will click on
I am creating a page that a user can click a link and it
My goal is to make the title of every external link equal to its
My goal is to change the onclick attribute of a link. I can do
Goal: When you click the text info in the column comments, a row should
My goal is to have a clickable link view details inside of the while

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.