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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:39:22+00:00 2026-06-18T06:39:22+00:00

I was doing some test with JQuery find , I have an html response

  • 0

I was doing some test with JQuery find , I have an html response coming from an AJAX request, so initially the result would be this.

<!DOCTYPE html>
<html>
<body>   
      <div id="dashboard">
        <div id="dash2">
            <h1>Hi</h1>
        </div>
    </div>
</body>
</html>

In My Ajax Success code is this..

success : function(response,status) {                       
    console.log( $(response).find('#dashboard').html() );
}

Upon printing it on the console that gives me an undefined.

However when I modify the response page(I created a nesting div) to this

<!DOCTYPE html>
<html>
<body>
        <div id="div1">
            <div id="dashboard">
                <div id="dash2">
                    <h1>Hi</h1>
                </div>
            </div>
        </div>
</body>
</html>

The line from my Ajax Success code returned console.log( $(response).find('#dashboard').html() ); returned the

<div id="dash2">
    <h1>Hi</h1>
</div>

My Question, How come on the first HTML when doing the console.log( $(response).find('#dashboard').html() ); it gave me an undefined, however on the second HTML(the one nested in the div) gave me the the contents of #dashboard(which the one I am expecting to get.

  • 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-18T06:39:23+00:00Added an answer on June 18, 2026 at 6:39 am

    As far as I know it is a browser dependent behavior to which tags to drop as a measure of sanitation, e.g. <head/>.

    The reason for not finding #dashboard while executing

    $(response).find('#dashboard')
    

    is most probably because #dashboard has become the root element after the sanitation, and .find() matches against the descendant elements not on the root itself.

    I normally to avoid this problem do this over an empty <div>.

    $("<div/>").html(response).find('#dashboard')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been doing some research on test driven development and find it pretty
Doing some jquery animation. I have certain divs set up with an attribute of
I'm have some that uses jQuery.clone() to get the html of a page and
I'm new in Silverlight and i am doing some tests. With my current test
I am doing some self-learning about JQuery. Here is the code for my very
I have a complex html-Form and am using jQ for some of the work
I have multiple html blocks in a jQuery cycle instance, like so: <div class=pane
I'm doing an jQuery ajax call to an XML page in my CakePHP site.
I'm trying to get to the bottom of some oddness between doing AJAX with
I'm having some trouble with an Ajax script which disables my jQuery click events.

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.