XMLHttpRequest not working as expected

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

    XMLHttpRequest not working as expected

    I am trying to implement XMLHttpRequest to a new website, but when I
    include HTML, the code appears as is, instead of the formated HTML. Please
    have a look and click the 1st link ("L'Association ") on top (yello
    horizontal bar on top): http://www.auriance.com/docs/alcan/index.php
    How can I fix it?
    Thanks,

    --
    Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
    Discover Opera: http://members.surfeu.fi/jerkku/
    http://www.auriance.com - http://www.auriance.net
  • Martin Honnen

    #2
    Re: XMLHttpRequest not working as expected



    Unknown User wrote:[color=blue]
    > I am trying to implement XMLHttpRequest to a new website, but when I
    > include HTML, the code appears as is, instead of the formated HTML.
    > Please have a look and click the 1st link ("L'Association ") on top
    > (yello horizontal bar on top):
    > http://www.auriance.com/docs/alcan/index.php
    > How can I fix it?[/color]

    Not sure what you complain about, you have

    function loadcode(File, Dest) {
    var req = new XMLHttpRequest( );
    if (req) {
    req.onreadystat echange = function() {
    if (req.readyState == 4 && req.status == 200) {
    removecode(Dest );
    var demo = document.getEle mentById(Dest);
    demo.appendChil d(document.crea teTextNode(req. responseText));
    }
    };
    req.open('GET', File);
    req.send(null);
    }
    }

    so you simply make a text node with the complete responseText and then
    insert that into the document, that is why you see the source you fetch.
    If you want to use responseText then you should set
    demo.innerHTML = req.responseTex t;
    but at least in Mozilla that is going to present problems as your page
    is served as application/xhtml+xml and innerHTML setting doesn't work
    there. But of course with Mozilla you could fetch XHTML (make sure you
    have the proper namespace on the elements then e.g.
    <div xmlns="http://www.w3.org/1999/xhtml">...</div>
    and then you can use responseXML and use importNode to copy the nodes
    into the existing document.
    For IE however you need another strategy.
    And that JavaScript file your page includes also seems to try to use
    Java via LiveConnect for Opera, I haven't looked close enough to tell
    you whether that emulation gives you more than responseText and how to
    use it, ask the author of that stuff.



    --

    Martin Honnen

    Comment

    • Unknown User

      #3
      Re: XMLHttpRequest not working as expected

      Thanks, it helped!


      On Mon, 07 Feb 2005 19:03:39 +0100, Martin Honnen <mahotrash@yaho o.de>
      wrote:
      [color=blue]
      >
      >
      > Unknown User wrote:[color=green]
      >> I am trying to implement XMLHttpRequest to a new website, but when I
      >> include HTML, the code appears as is, instead of the formated HTML.
      >> Please have a look and click the 1st link ("L'Association ") on top
      >> (yello horizontal bar on top):
      >> http://www.auriance.com/docs/alcan/index.php
      >> How can I fix it?[/color]
      >
      > Not sure what you complain about, you have
      >
      > function loadcode(File, Dest) {
      > var req = new XMLHttpRequest( );
      > if (req) {
      > req.onreadystat echange = function() {
      > if (req.readyState == 4 && req.status == 200) {
      > removecode(Dest );
      > var demo = document.getEle mentById(Dest);
      > demo.appendChil d(document.crea teTextNode(req. responseText));
      > }
      > };
      > req.open('GET', File);
      > req.send(null);
      > }
      > }
      >
      > so you simply make a text node with the complete responseText and then
      > insert that into the document, that is why you see the source you fetch.
      > If you want to use responseText then you should set
      > demo.innerHTML = req.responseTex t;
      > but at least in Mozilla that is going to present problems as your page
      > is served as application/xhtml+xml and innerHTML setting doesn't work
      > there. But of course with Mozilla you could fetch XHTML (make sure you
      > have the proper namespace on the elements then e.g.
      > <div xmlns="http://www.w3.org/1999/xhtml">...</div>
      > and then you can use responseXML and use importNode to copy the nodes
      > into the existing document.
      > For IE however you need another strategy.
      > And that JavaScript file your page includes also seems to try to use
      > Java via LiveConnect for Opera, I haven't looked close enough to tell
      > you whether that emulation gives you more than responseText and how to
      > use it, ask the author of that stuff.
      >
      >
      >[/color]



      --
      Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
      Discover Opera: http://members.surfeu.fi/jerkku/
      http://www.auriance.com - http://www.auriance.net

      Comment

      Working...