never mind, it's really work now, filter is great, thanks.

On 1月13日, 下午7時19分, "David .Wu" <chan1...@gmail.com> wrote:
> nope, it's doesn't work, I type the wrong character but something
> interesting happened
>
> $('#response').html($(res).filter('#a').text());  <- it's not work
> $('#response').html($(res).filter('$a').text());  <- it's give me 123,
> but not truly work,
> $('#response').html($(res).text());  <- it's not work the same meaning
> like above, it response text part from responseText
>
> On 1月12日, 下午5時03分, Balazs Endresz <balazs.endr...@gmail.com> wrote:
>
> > Use filter with $.ajax:
> > $('#response').html($(res).filter('#a').text());
>
> > On Jan 12, 9:30 am, "David .Wu" <chan1...@gmail.com> wrote:
>
> > > And I found the load is not work either, because it still get the
> > > construct not the value
> > > for example
>
> > > <div id="test"></div>
>
> > > $(document).ready(function)
> > > {
> > >         $('#test').load('ajax.php #a');
>
> > > });
>
> > > and the result was
> > > <div id="test"><div id="a">123</div></div>, what I exactly want is
> > > <div id="test">123</div>
>
> > > On 1月11日, 下午8時13分, Balazs Endresz <balazs.endr...@gmail.com> wrote:
>
> > > > As jQuery parses this html the output will contain three elements:
> > > > title, meta, and the div instead of the single html. So .find() won't
> > > > work because it will search in the descendant elements, but filter
> > > > will return '#a' because it's an element of the current jQuery object.
>
> > > > $('<html></html>') doesn't work either, I guess it's not possible to
> > > > create an html element so easily.
>
> > > > You can also try setting the dataType option to html (or maybe xml).
>
> > > > On Jan 11, 11:13 am, "David .Wu" <chan1...@gmail.com> wrote:
>
> > > > > 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.

Reply via email to