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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:53:49+00:00 2026-05-24T06:53:49+00:00

HTML: <html> <head> <title></title> </head> <body> <div class=mainContainer> dgdhgdhgd <div class=header></div> <div class=navigation></div> <div

  • 0

HTML:

 <html> 
     <head>
         <title></title> 
     </head>
     <body>
         <div class="mainContainer"> dgdhgdhgd 
             <div class="header"></div>
             <div class="navigation"></div>
             <div class="content"></div>
             <div class="footer"></div>
         </div>
     </body>
 </html>

jQuery:

 <script type="text/javascript">

         $(function() {
             alert("hsahdjkha");
             $('#form1').append('<span id="result" ></span>');

             $('#result').load('sageframetemplating/layout.html', function() {
                 alert('Load was performed.');
                 $('#result').find('body').html();
                 alert($('#result').html());
                 test();
             });

         });

         function test() {
             $.ajax({
                 type: "POST",
                 url: "Default.aspx/Result",
                 data: "{ result:'" + $('#result').html() + "'}",
                 contentType: "application/json; charset=utf-8",
                 dataType: "json",
                 success: function(response) {
                     alert("Wa hooooooooo");
                 },
                 error: function() {
                     alert("error");
                 }
             });
         }

     </script>

I want to catch only body part of the HTML but I get:

<title></title> 
<div class="mainContainer"> dgdhgdhgd 
    <div class="header"></div>
    <div class="navigation"></div>
    <div class="content"></div>
    <div class="footer"></div>
</div>

How it possible to catch only body part?

  • 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-24T06:53:49+00:00Added an answer on May 24, 2026 at 6:53 am

    The problem is you are trying to insert a block of HTML containing a <body> and a <head> tag into the page.

    Since you can’t have multiple <body> tags within the page, they get stripped out, leaving you with the output you see.

    One possible solution is to use $.get() instead — which doesn’t dump the data straight into the page — and parse the data before putting it into the page.

    $.get('sageframetemplating/layout.html', function(data) {
        var parsedData = $(data).find("body").html();
        $("#result").html(parsedData);
    });
    

    I’ll admit I wrote this without any testing on my end, so you may have to clean up the syntax yourself.

    EDIT

    From html() docs:

    This method is not available on XML documents.

    Terrific.

    The data object is really a Document object, which has a method getElementsByTagName() which allows us to hack around with it and get our hands on a NodeList. If we then access the first item in the list, we get a Node:

    var node = data.getElementsByTagName("body")[0]
    

    At this point we can extract the results:

    $("#result").append($(node).children())
    

    This dirty, dirty hack will get you what you want for this very specific scenario.

    Note can do horrible things if your page contains scripts.

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

Sidebar

Related Questions

The code is as below: <html> <head> <title>test</title> </head> <body> <div><span>shanghai</span><span class=margin> </span><span>male</span></div> </body>
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
I have the following HTML markup: <body> <div class=wrapper> <div class=head> <p class=title>title</p> <a
<!DOCTYPE HTML> <html> <head> <meta content=text/html; charset=utf-8 http-equiv=Content-Type /> <title>abc</title> <script type=text/javascript src=scripts/jquery_latest.js></script> <script
See example: <!DOCTYPE html> <html> <head> <title>language</title> <script type=text/javascript src=http://www.google.com/jsapi> </script> </head> <body> <div
I am using this HTML <html> <head> <Title>EBAY Search</title> </head> <script language=JavaScript src=ajaxlib.js></script> <body>
I have the following code <html> <head> <title>Test</title> <style type=text/css> <!-- body,td,th { color:
Take a look at this html: <head> <title>Test page</title> <script type=text/javascript> function submitForm() {
Heres my simple html source <html> <head> <title> Dec2Bin </title> <script type=text/javascript> function app()
HTML: <html> <head> <meta http-equiv=Content-Type content=text/html; charset=UTF-8> <title></title> <link type=text/css href=galerina.css rel=stylesheet/> </head> <body>

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.