This is my testing php code, I found if I use filter, I can only get the content from first level of object, for example <div id="res">1<div id="res2">2</div></div>
I can get res's contents by filter, but I can't get res2's contents, is that possible that get any thing I want through ajax? <?php if (isset($_POST['g'])) { echo '<div id="res">1<div id="res2">2</div></div>'; exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>get</title> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> </head> <body> <div id="show"></div> <input type="button" id="btn1" value="btn1" /> <input type="button" id="btn2" value="btn2" /> <script> $(function() { $('#btn1').click(function() { $.post('get.php', {g: 1}, function(data) { var data = $(data).filter('#res').html(); $('#show').html(data); }); }); $('#btn2').click(function() { $.post('get.php', {g: 1}, function(data) { var data = $(data).filter('#res2').html(); $('#show').html(data); }); }); }); </script> </body> </html>