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

  • Home
  • SEARCH
  • 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 443463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:10:25+00:00 2026-05-12T21:10:25+00:00

As I understand it, the JQuery load() function retrieves a document and can perform

  • 0

As I understand it, the JQuery load() function retrieves a document and can perform the quivelent of:

$('#somecontenttograb').html()

upon it. I would like to know how to do that… In essence, I want to use JQuery to asynchronously download a web page and then grab elements from it and insert them into my own document at different places.

I’m thinking the .ajax call is good here, but I’m having trouble understanding the returned object – I believe the argument passed to the success function could have it’s elements pulled out, but how?

Thanks,

Matt.

Having tried the code posted in the two answers below, I have tried this and while I can use an alert to show me the url being passed to the ajax() call and the success function gets called, if I alert the $(result).find(‘#content’) only null appears in the alert. If I put the url from the first alert into a browser, I get a valid page back. What could be going wrong?

Matt.

  • 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-12T21:10:25+00:00Added an answer on May 12, 2026 at 9:10 pm

    UPDATE

    In response to the comments you’ve left on other answers, I just want to make sure I understand the situation clearly:

    • You’re testing from your localhost, not from the local hard drive (meaning your URL in the browser includes “http://localhost“, and not a location on your hard drive.
    • When you make the AJAX response, alert(...)-ing the result give you null, or some equivalent.
    • The URL is valid and can be loaded in your browser.
    • The URL you’re requesting is within the same domain as the originating page.

    If those things are true, then I’d try the following do some troubleshooting:

    1. Use Firefox and install Firebug (we’ll need this to determine if AJAX requests are failing, and why)
    2. Include some logging in your code using Firebug’s console
    3. Use jQuery’s ajax(...) method, and handle failure by including some logging code to see what happened. You may be able to avoid this step if the page you’re on doesn’t need a visual response for a failed request and you’re using Firebug.

    Here’s the code I would use for this:

    $.ajax({
        url: "http://stackoverflow.com/",
        success: function(html) {
            var responseDoc = $(html);
            // Output the resulting jQuery object to the console
            console.log("Response HTML: ", responseDoc);
        }
        // Handle request failure here
        error: function(){
            console.log("Failure args: ", arguments);
        }
    });
    

    If you post the output of your Firebug logs, it should be easier to figure out the problem and find a solution for you. Firebug also logs XMLHttpRequests so you can see exactly what is being sent to and from the server, and Firebug will change the look of the request if it returns some kind of server error (which is how you could avoid #3 of the things I listed above).


    You could use the ajax(...) method, but it would be easier to use get(...) with a callback, like this:

    $.get("http://stackoverflow.com", function(html) {
        var responseDoc = $(html);
    });
    

    responseDoc will be a jQuery object you can use to extract elements from and treat just like you would any other jQuery object. You can extract stuff from the responseDoc and add it into your main document any way you want, using the jQuery manipulation methods.

    If you need the extra functionality the $.ajax(...) method provides, you would use the following code.

    $.ajax({
        url: "http://stackoverflow.com/",
        success: function(html) {
            var responseDoc = $(html);
        }
        error: function(XMLHttpRequest, textStatus, errorThrown){
            // Handle errors here
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 437k
  • Answers 437k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Ah ok, I see what you mean now... public IEnumerable<string>… May 15, 2026 at 4:19 pm
  • Editorial Team
    Editorial Team added an answer For the first rebase do this: git checkout -b rebased… May 15, 2026 at 4:19 pm
  • Editorial Team
    Editorial Team added an answer You are passing the double pointer "matrix2" by value. Therefore,… May 15, 2026 at 4:19 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.