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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:59:46+00:00 2026-06-13T23:59:46+00:00

I have an ajax call with the following success function: success: function(response){ console.log($(response).siblings()); $(response).siblings().each(function(){

  • 0

I have an ajax call with the following success function:

            success: function(response){
                console.log($(response).siblings());
                $(response).siblings().each(function(){
                    alert("foo");
                    var thing_id = $(this).attr("id").split("-")[0];
                    alert(thing_id);
                    $("#"+thing_id).append(this);
                })

where response is rendered html using this django template (slightly anonymized):

{% for thing in things %}
    <div id="{{ thing.something.id }}-pc">
        <div>
            <span class="tablename">Something Else</span>
            {% include '<some template>' with table=thing.something_else %}
        </div>

    </div>
{% endfor %}

the docs for sibling() state that the selector is not included, which is what I see if I only have one thing in things in my template, but if I have more than one, I get both top level divs alerted in the loop.

What’s going on?!

EDIT (better question): why am I getting both top level divs when there are 2, but 0 when there is only 1, when I call siblings() on $(response)?

Seems like I’m misunderstanding what I’m selecting with $(response). Can anyone clarify?

  • 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-13T23:59:47+00:00Added an answer on June 13, 2026 at 11:59 pm

    “So what am I selecting when I say $(response)?”

    That gives you a jQuery object that includes all of the top-level elements in your response string. If there were, say, three top-level elements then $(response).length will be 3.

    $(response).siblings() then gives you all of the siblings of all of the top-level elements, and because each is a sibling of the other(s) this again returns all of the top-level elements.

    If there is only one top-level element then it has no siblings.

    So obviously .siblings() is the wrong method to be using here, but I’m not sure what to advise you to use instead because your desired result is still unclear.

    You can loop through each top-level element with:

    $(response).each(function() {...
    

    To get a particular one you can use .eq(someZeroBasedIndex), e.g., $(response).eq(1) to get the second.

    To get all except the first you can use $(response).slice(1).

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

Sidebar

Related Questions

I have the following AJAX call: $('#FonykerUsernameRegister').blur(function(){ if($(this).val().length > 2) { alert($(this).val()); $.ajax({ url:
I have the following ajax call var prev_sibling = $(this).prev().attr(value); var next_sibling = $(this).next().attr(value);
The problem is the following. We have lots of ajax call via $.ajax function.
I have the following code to make a jsonp call. var contacts; $.ajax({ url:
I have following ajax call and response with json data type. Currently I write
I have following ajax call: $(#container).html(loading...); $.ajax({ url: somedoc.php, type: POST, dataType: html, success:
I have a simple ajax call: $.ajax({url: my_url_here, dataType: 'text', success: function(data, textStatus) {
If I have the following ajax call (inside a function) how do I go
I have the following ajax call in a function, which is called upon a
I have an ajax call that fires multiple times but is called once. function

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.