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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:14:21+00:00 2026-06-14T15:14:21+00:00

The following code sends an alert to the screen as ‘undefined’. I would like

  • 0

The following code sends an alert to the screen as ‘undefined’. I would like to alert the html of #div.

    $.ajax({
        type: "POST",
        url: pageurl,
        dataType: "html",
        success: function(data){
            alert($(data).children("#div").html());
        }       
    });

I could do something like in load, but I don’t think I’m allowed:

    url: pageurl + ' #div'

How can I resolve this?

UPDATE: Based on advice from @Murali, I’ve tried the following, but it still doesn’t behave as I would like:

<html>
<head>
<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {  
    $.ajax({
            type: "POST",
            url: 'index.html',
            dataType: "html",
            success: function (data) {                    
                alert($(data).find('#site-content').html());
            }
        });
});
  </script>

<title></title>
</head>
<body>
<div id="site-content">
    some data</div>
</body>
</html>
  • 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-14T15:14:22+00:00Added an answer on June 14, 2026 at 3:14 pm

    Try

    Change this

     $(data).children("#div").html()
    

    To

     $(data).find('#yourDivId').html()
    

    Note: yourDivId -> give the id of the div. In your code you mentioned as ‘#div’ not sure whether really your code is like <div id='div'>

    Code i tried

    in Index.html

          $.ajax({
                type: "POST",
                url: 'page.html',
                dataType: "html",
                success: function (data) {                    
                    $(data).find('#site-content').html();
                }
            });
    

    In Page.html

     <head>
    <title></title>
    </head>
    <body>
    <div id="site-content">
        some data</div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code . var last_id = ''; $('.products').each(function(){ $.ajax({ type: POST,
I have the following code: jQuery.ajax({ type: POST, async: true, url: '/index/city', data: {massiv:
All, I have the following code: $.post(save.php, {rate: value, vendor: vendor_id}, function(results) { alert(results);
The following code inside the tags gives error: Object Expected. <!-- JQuery/AJAX--> <script type=text/javascript>
The following code sends me an email holding the following variables. One of the
Following is the code which listens on a port for HTTP requests and sends
I have the following code that works on PHP5 to send a HTTP POST
i have following code for inserting another page into div An XHTML 1.0 Strict
In the following code, I have a div around each row in a table
Consider the following code: index.html <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd> <html> <head>

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.