how can i find div tag from ajax.responseText (type:string)

Discussion in 'HTML & Website Design' started by zhoufenglei, Aug 3, 2009.

  1. #1
    hello everyone!
    I'm using ajax of jquery to get the content of one page.Specifically i get the whole page content like this:
    <!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>
    <title></title>
    </head>
    <body>
    <div id="demo">content</div>
    </body>
    </html>
    now i want to get the content of div named "demo". i can get whole page content with jquery ajax,but i can't find div innerHTML.help me.
     
    zhoufenglei, Aug 3, 2009 IP
  2. jamieellis

    jamieellis Active Member

    Messages:
    427
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    You may be able to do this using a regular expression. Or if the XHTML is strict you could read the document in as XML using responseXML and then just select the node you want to read.
     
    jamieellis, Aug 3, 2009 IP