I tried all your suggestion, but got some weired result. ajax.html <!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>ajax</title> <script type="text/javascript" src="js/jquery-1.2.6.js"></script> </head>
<body> <div id="response"></div> <input name="btn" type="button" value="ajax" id="btn" /> <script language="javascript"> <!-- $(document).ready(function() { $('#btn').click(function() { $.ajax( { url:'ajax.php', cache:false, success:function(res) { $('#response').html($('#a',res).text()); //got nothing $('#response').html($(res + ' #a').text()); //got ajaxtest contents $('#response').html($(res).find('#a').text()); //got nothing } }); }); }); //--> </script> </body> </html> ajax.php <!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>ajax</title> </head> <body> <div id="a">test contents</div> </body> </html> On 1月10日, 上午2時11分, dropcube <ronnyh...@gmail.com> wrote: > > is there any way to get the value 123 straight from div? > > yes, just apply a jQuery selector to the response content and get > whatever you need. In this example: > > $('#a', res).text(); > > OR > > $(res).find('#a').text(); > > You can also try with $.load that allows you to specify a jQuery > selector in the URL.