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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:03:20+00:00 2026-05-13T06:03:20+00:00

So far I’ve been making an AJAX call to replace the content of a

  • 0

So far I’ve been making an AJAX call to replace the content of a div with another page, using the following code:

<script>
    function fetchContainerContent(url, containerid) {
        var req = false

        if (window.ActiveXObject) {
            try {
                req = new ActiveXObject("Msxml2.XMLHTTP")
            } catch (e) {
                try {
                    req = new ActiveXObject("Microsoft.XMLHTTP")
                } catch (e) {}
            }
        } else if (window.XMLHttpRequest) {
            req = new XMLHttpRequest()
        } else {
            return false
        }

        req.onreadystatechange = function() {
            requestContainerContent(req, containerid)
        }
        req.open('GET', url, true)
        req.send(null)
    }

    function requestContainerContent(req, containerid) {
        if (req.readyState == 4 && (req.status==200 || window.location.href.indexOf("http")==-1))
            document.getElementById(containerid).innerHTML = req.responseText
    }
</script>

I have tried transforming the above code to work with jQuery as below but it doesn’t work. In other words, I am trying to mimic the end result of the above behaviour but it is nowhere near the same. In fact, nothing happens on screen, nothing changes. I should mention that I don’t really need the Loading… but since the examples I’ve seen use it and since I’m not sure how to correctly syntax jQuery, I’ve left it in.

<script>
    function fetchContainerContent(url, containerid) {
        jQuery.ajaxSetup ({
            cache: false
        });
        var ajax_load = "loading...' />";

        jQuery("#load_basic").click(function() {
            jQuery("#"+containerid).html(ajax_load).load(url);
        });
    }
</script>

Thanks in advance. I’m really new to jQuery so I may have done something really stupid.

After all the comments received (thanks guys!) I have left only the following:

function fetchContainerContent(url, containerid){                   
var ajax_load = "loading...";               
$("#load_basic").click(function(){$("#"+containerid).html(ajax_load).load(url);});

}

but I’m still having problems as it does not update the page. No js error, nothing happens.

  • 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-13T06:03:20+00:00Added an answer on May 13, 2026 at 6:03 am

    The only fundamental differences I see are:

    1. You’re using a hacky-looking loading string "loading...' />". This doesn’t smell good.
    2. You’re hardcoding the containerid with "#result" instead of using "#" + containerid.
    3. You’re defining the click event in JS code rather than (apparently) inline in the element. How did it originally look like?

    For the remnant the code looks fine.

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

Sidebar

Related Questions

So far I have been using in tutorials, examples and sample code only packages
So far i have the following code, but it doesn't seem to be working,
So far I have been able to compile my Java programs in Linux using
So far I've been setting up redirects for single pages on my ASP.NET site
So far I have only been updated a view from within its controller. I
As far as my understanding after reading and researching, the purpose of using salt
Basically, what I'm trying to create is a page of div tags, each has
as far as I can get gowalla auth code response contains both expires_at and
As far as I remember, in pure W3C event model (that means, using addEventListener),
So far i wrote a code to download a file from ftp server then

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.