Node Replacement without HTML tags & empty responseXML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anand

    #1

    Node Replacement without HTML tags & empty responseXML


    The situation is; I receive a response back from the server which i
    only a part of html code. e.g. a table like <table
    <tr><td>high</td></tr>........ </table>. In other words, I receive
    file as a response which has a part of html file.

    My aim is to replace an existing document node with the new response.

    If I run the following lines (JavaScript):

    var parsedText = document.create TextNode(req.re sponseText);
    body.replaceChi ld(parsedText, toReplace)

    It replaces the node 'toReplace' with html codes with the tags include
    which is not what I want. The html tags are not wanted but shoul
    display in correct format as specified by html (a tabular form if htm
    tag is <table>)

    If I try:

    alert(responseX ML); (its blank.... nth gets displayed in the aler
    message)
    var parsedText = document.create TextNode(req.re sponseXML);
    body.replaceChi ld(parsedText, toReplace); (it replaces toReplace b
    "[object]" in IE6)


    Any kind of help will be appreciated.

    Anan

    --
    Anan
    -----------------------------------------------------------------------
    Anand's Profile: http://www.highdots.com/forums/member.php?userid=7
    View this thread: http://www.highdots.com/forums/showthread.php?t=123946

  • Anand

    #2
    Re: Node Replacement without HTML tags &amp; empty responseXML


    a similar issue was on this same form


    but it ended up without any specific solution..... and not ver
    relevant to me either


    Anan

    --
    Anan
    -----------------------------------------------------------------------
    Anand's Profile: http://www.highdots.com/forums/member.php?userid=7
    View this thread: http://www.highdots.com/forums/showthread.php?t=123946

    Comment

    • Martin Honnen

      #3
      Re: Node Replacement without HTML tags &amp; empty responseXML



      Anand wrote:
      [color=blue]
      > The situation is; I receive a response back from the server which is
      > only a part of html code. e.g. a table like <table>
      > <tr><td>high</td></tr>........ </table>. In other words, I receive a
      > file as a response which has a part of html file.
      >
      > My aim is to replace an existing document node with the new response.
      >
      > If I run the following lines (JavaScript):
      >
      > var parsedText = document.create TextNode(req.re sponseText);
      > body.replaceChi ld(parsedText, toReplace)[/color]

      How about
      toReplace.inner HTML = req.responseTex t;
      ? That should do what you want. Note that there might be smarter ways of
      doing things if you use Mozilla as there you could directly load XHTML
      and then use DOM importNode but as you have not shown us the context the
      innerHTML assigment is probably your best bet at cross browser replacement.


      --

      Martin Honnen
      http://JavaScript.FAQTs.com/

      Comment

      • Anand

        #4
        Re: Node Replacement without HTML tags &amp; empty responseXML


        that worked for me.


        Thanks a lo

        --
        Anan
        -----------------------------------------------------------------------
        Anand's Profile: http://www.highdots.com/forums/member.php?userid=7
        View this thread: http://www.highdots.com/forums/showthread.php?t=123946

        Comment

        • Anand

          #5
          Re: Node Replacement without HTML tags &amp; empty responseXML


          One more question on this issue.
          Can I treat the req.responseTex t as a string an manipulate it? By tha
          I mean, if I am sent two different tables to be inserted at tw
          different locations, I will have to be able to access the response an
          separate those two tables before inserting them at specifie
          locations.

          e.g. If my response is as shown below

          INSERT IN PARENT NODE: 'FORM'
          <table id="mytable">
          ...
          ...
          </table>

          INSERT IN PARENT NODE: 'DIV'
          <table id = "yourtable" >
          ...
          ...
          </table>

          Can I access it via 'for' loop or any other method so that I ca
          extract each table using some code in javascript?

          Anan

          --
          Anan
          -----------------------------------------------------------------------
          Anand's Profile: http://www.highdots.com/forums/member.php?userid=7
          View this thread: http://www.highdots.com/forums/showthread.php?t=123946

          Comment

          Working...