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

  • Home
  • SEARCH
  • 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 6321313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:07:40+00:00 2026-05-24T16:07:40+00:00

The response is a HTML document (from a request from a link’s href) var

  • 0

The response is a HTML document (from a request from a link’s href)

 var data = $(response).find('body').html();
 alert(data);  

 // I get a alert with nothing...

full code:

     $.ajax({
       url: $(this).attr('href'),
       type: 'GET',      
       success: function(response){
         var data = $(response).find('body').html();
         alert(data);  
        }
     });
  • 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-24T16:07:41+00:00Added an answer on May 24, 2026 at 4:07 pm

    Use this tricky code 😉

       /*this will get the body content and head by replacing them with div before placing them inside the jQuery factory witch will avoid all bugs, i used this while creating the ajaxit jquery plugin :) */
    $.ajax({
                    type: "GET",
                    url: $(this).attr('href'),
                    async:true,
                    error:function (event, request, options, error) {
                        if (ajaxItMain.onError){
                            ajaxItMain.onError(event,request,options,error);
                        }
                    },
                    success:  function (data) {
                        // ----------------- < data >
                        // clearing CDATA
                        data=data.replace(/\<\!\[CDATA\[\/\/\>\<\!\-\-/gi,'');
                        data=data.replace(/\/\/\-\-\>\<\!\]\]\>/gi,'');
    
                        // extracting the the head and body tags
                        var dataHead = data.match(/<\s*head.*>[\s\S]*<\s*\/head\s*>/ig).join("");
                        var dataBody = data.match(/<\s*body.*>[\s\S]*<\s*\/body\s*>/ig).join("");
                        var dataTitle = data.match(/<\s*title.*>[\s\S]*<\s*\/title\s*>/ig).join("");
    
                        dataHead  = dataHead.replace(/<\s*head/gi,"<div");
                        dataHead  = dataHead.replace(/<\s*\/head/gi,"</div");
    
                        dataBody  = dataBody.replace(/<\s*body/gi,"<div");
                        dataBody  = dataBody.replace(/<\s*\/body/gi,"</div");
    
                        dataTitle = dataTitle.replace(/<\s*title/gi,"<div");
                        dataTitle = dataTitle.replace(/<\s*\/title/gi,"</div");
    
    
                        // comments
                        var commentPattern = /\<\!\-\-([\s\S]*?)\-\-\>/ig;
    
                        // get head comment tags
                        var headComments = dataHead.match(commentPattern);
    
                        // get body comment tags
                        var bodyComments = dataBody.match(commentPattern);
    
                        // head - body - title content
                        var $dataHead    = $(dataHead);
                        var $dataTitle   = $(dataTitle);
                        var $dataBody    = $(dataBody);
                    }
                });
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am inserting the HTML response from an AJAX call into my page, but
I am having C function. From the html page, through ajaxcall the request is
I'm using the following in the web page but can't get a response from
Let's assume, for instance, an xHTML document as below: <html> <head> </head> <body> <div
Odd - I can't seem to use a jQuery.get() to read the response from
I'm trying to retrieve JSON data from servlet and display in html. I was
I am trying to read the response from an xhr request. I do not
i have a page where i pull some html from an ajax request and
Trying to post a form with jquery and the response data is the html
I'm trying to make a request using dojo.xhrGet to grab some XML data from

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.