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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:45:37+00:00 2026-05-20T11:45:37+00:00

I am new studing jquery.ajax. I still have some question. how to receive data

  • 0

I am new studing jquery.ajax. I still have some question. how to receive data from another page’s div? I am tried to do this: open a.php, send html data from div#send to b.php, then return the data from b.php div#aa and show in a.php div#result, from b.php div#bb and show in a.php div#text. Thanks.

a.php

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script> 
<script language="javascript"> 
$(document).ready(function () {      
var params = "value=" + $('#send').text();   
$.ajax({        
     url:'b.php',        
     type:'post',                 
     dataType:'html',            
     data:params,            
     success:data     
     }); 
function data (html) {   
$("#result").html('#aa'); 
$("#text").html('#bb'); 
} 
}); 
</script>
<body>
<div id="result"></div>// I need return 'this is an apple.'
<div id="text"></div>//I need return 'A red apple'.
<div id="send">apple</div>

b.php

<?php
echo '<div id="aa">';
echo 'This is an '.$_REQUEST['value'].'.'; 
echo '</div>';
echo '<div id="bb">';
echo 'A red '.$_REQUEST['value'].'.'; 
echo '</div>';
?>
  • 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-20T11:45:37+00:00Added an answer on May 20, 2026 at 11:45 am

    You need to turn the response string into DOM elements, select those elements, and append them where you want.

    function data (html) {
        var $html = $( html );             // create DOM elements in a jQuery object
    
        $html.filter('#aa').appendTo("#result"); // filter out the '#aa' element and
                                                 //    append it to '#result'
    
        $html.filter('#bb').appendTo("#text");   // filter out the '#bb' element and
                                                 //    append it to '#text'
    }
    

    I used the filter()[docs] method because the elements you’re targeting appear to be at the top level of the HTML response.

    If they were nested deeper, you’d use the find()[docs] method instead.

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

Sidebar

Related Questions

I am new to studying jquery.ajax. I want to paste some data from a.php
I am new to studying jquery.ajax. Through some tutorials, I tried some code by
I'm pretty new to WordPress but have spent some 50 odd hours studying up
I'm new at web development with .NET, and I'm currently studying a page where
New Question I am looking for a way in Javascript to get the parent
New to FluentNHibernate =D I have a parent/children classes as follows: public class Parent
new to JBoss and am configuring some applications. I know how to do this
My jqGrid that does a great job of pulling data from my database, but
I'm designing a new web project and, after studying some options aiming scalability, I
Problem I'm fairly new to design patterns, and have been studying the book, 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.