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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:44:04+00:00 2026-05-17T00:44:04+00:00

This is the first thing I write in javascript, so I hope its a

  • 0

This is the first thing I write in javascript, so I hope its a basic error

What I’m trying to achieve here:
Take a bunch of links from a page, load their contents query for links inside and add them to a list on current page.

I get error on the append
And in JQ documentation they say the method can get a JQ object

<script type="text/javascript">
    $(document).ready(function () {
        var wtf = $(".download");
        var links = $("a", wtf)
        links.each(function (index) {
            var newFrame = document.createElement("div");
            $(newFrame).load($(this).context.href, function (response, status, xhr) {
                if (status == "error") {
                    alert("error");
                }
                $("a", response).each(function (index) {
                    $("#results").append($(this));
                });
            });
            //  $("#results").append(newFrame);
        });
    });
</script>
  • 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-17T00:44:05+00:00Added an answer on May 17, 2026 at 12:44 am

    Let’s see if my guessing error checking abilities are good enough for this:

    // No point really in using context here.
    // This would be better, or at least more readable
    var links = $(".download a");
    
    // No need to add in the argument if you're not actually going to use it
    links.each(function() {
        // Doing this will get you create the jQuery object
        // without having to use the DOM createElement method
        var newFrame = $('<div />');
    
        // this.href is shorter and neater
        newFrame.load(this.href, {
            'html': '.ajax'
        }, function(response, status, xhr) {
            if (status == "error") {
                console.log(xhr);
            }
    
            // This is the odd part - response is a selector?
            // This should loop through each anchor that are a child
            // Of the element selected by the response receieved
            // Using appendTo here is better than looping through
            // each element and using .append() there
            $(response).find("a").appendTo("#results");
    
            // And finally of course because this is .load()
            // Remember that the actual response is also
            // appeneded to the element in question,
            // hence the extra .ajax appearing there
        });
    
        // This occures outside of callback,
        // so it's actually executed *before* the code above
        $("#results").append(newFrame);
    });
    

    See jsfiddle for this piece of code actually working: http://jsfiddle.net/E589q/4/

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

Sidebar

Related Questions

I'm a jquery novice trying to write my first app here and one thing
I am trying to achieve 2 things with the href links below. First, I
Trying to write better JavaScript, woohoo! First step for me: YUILoader dependency loader so
I was just reading this line: The first thing the format() method does is
I'm going a little mad I think. This is the VERY first thing I
Suppose I have a doc structure like this: thing: { name: { first: John,
I am trying to write a simple if statement in javascript (jquery library) that
I'm trying to write a helper method in JavaScript. It should act differently if
So I'm a beginner at this whole javascript thing, and this is probably a
I am trying to make a typewriter effect in javascript using array. At first

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.