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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:02:18+00:00 2026-06-17T01:02:18+00:00

My purpose is, I want to take specific html out from data and update

  • 0

My purpose is, I want to take specific html out from data and update that area only.

How do I filter the returned data from jQuery.ajax?

This link is a old post but I do have the exactly same problem.

The solution giving from the link is $("[ref=B]").html(data).find( '[ref=A]' );

However, if I do so, the entire page will write on <span ref='B'> first then find the selector inside of it…..

The alternative way to only find ‘[ref=A]’ is

html = $(data).filter('[ref=B]').find('[ref=A]').html() // this way will work

none of these will work

$(data).find('[ref=A]').html();
$(data).filter('[ref=A]').html();
$(data).filter('body').html();
$(data).find('body').html();

HTML

`<body>

<span ref='B'><span ref='A'>abc</span></span>

</body>`

JS

 $(function() {
$.get(window.location.pathname + window.location.search, function(data){ alert(data);});
 });

Returned Data

<html>
<body>
    <span ref='B'><span ref='A'>abc</span></span>
</body>
</html>

My question is, is there a solution to filter body`s html from data which returned from $.ajax?? like

body_html = $(data).??????? 

then I can do whatever I want, like

body_html.find('xxxx');

Thank you very much for your advice.

  • 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-17T01:02:19+00:00Added an answer on June 17, 2026 at 1:02 am

    You can use a DocumentFragment to simulate your html and do your search without appending it to the DOM.

    // Create your DocumentFragment to be able to work without DOM
    var body_html = document.createDocumentFragment();
    
    // Convert and append data from your jQuery to work with fragment
    body_html.appendChild($(data)[0]);
    
    // Now you can select using your jQuery
    var $body_html = $(body_html);
    
    // Now you can use the find or whatever you want, like if it was in the DOM
    $body_html.find('.foo');
    
    // Or you can append in your current document, 
    // but attention, after it the fragment reference is erased
    $body_html.appendTo(document.body); 
    // now you need to get reference again from body, 
    // because your fragment doesn't exists anymore.
    
    // So... if you try:
    console.log(body_html); // undefined
    console.log($body_html); // jquery over undefined, probably just a jquery useless
    
    // At this point you will need to reference from DOM to continue manipulation
    $body_html = $(document.body);
    // Now I'm ready to continue the work
    // This var is like your DocumentFragment, but already on DOM.
    

    You also can do a filter in jQuery templating $(data).filter('.foo') but as you can see in this tests, your performance will drop a lot.

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

Sidebar

Related Questions

I am building a custom web panel control for specific purpose.I want the control
I want to compile the data for reporting purpose, using php communicating with postgres,
I want to create a widget that contains several QDockWidgets on purpose of putting
I want to do a simulation on Fraunhofer diffraction and for that purpose I
I want build a data structure to store limited undo buffer, take store 6
I want to take the URL from request.path in a template and do a
I want to get and save data from a cell on event of UILongPressGestureRecognizer.
purpose:i want to limit the times that a task can make syscall. so,i add
I want to create a helper method that can take in ANY type of
I want to create a purpose built device capable of running a java vm

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.