XMLHttpRequest not working as expected

Discussion in 'Javascript' started by Unknown User, Feb 7, 2005.

  1. Unknown User

    Unknown User Guest

    Unknown User, Feb 7, 2005
    #1
    1. Advertising

  2. Unknown User wrote:
    > 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?


    Not sure what you complain about, you have

    function loadcode(File, Dest) {
    var req = new XMLHttpRequest();
    if (req) {
    req.onreadystatechange = function() {
    if (req.readyState == 4 && req.status == 200) {
    removecode(Dest);
    var demo = document.getElementById(Dest);
    demo.appendChild(document.createTextNode(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.responseText;
    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
    http://JavaScript.FAQTs.com/
    Martin Honnen, Feb 7, 2005
    #2
    1. Advertising

  3. Unknown User

    Unknown User Guest

    Thanks, it helped!


    On Mon, 07 Feb 2005 19:03:39 +0100, Martin Honnen <>
    wrote:

    >
    >
    > Unknown User wrote:
    >> 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?

    >
    > Not sure what you complain about, you have
    >
    > function loadcode(File, Dest) {
    > var req = new XMLHttpRequest();
    > if (req) {
    > req.onreadystatechange = function() {
    > if (req.readyState == 4 && req.status == 200) {
    > removecode(Dest);
    > var demo = document.getElementById(Dest);
    > demo.appendChild(document.createTextNode(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.responseText;
    > 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.
    >
    >
    >




    --
    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
    Unknown User, Feb 8, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Huff
    Replies:
    2
    Views:
    390
    Richard Huff
    Jan 6, 2004
  2. =?Utf-8?B?QnJhdm8=?=

    XMLHTTPRequest with Xpath is not working

    =?Utf-8?B?QnJhdm8=?=, Apr 1, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    523
    =?Utf-8?B?QnJhdm8=?=
    Apr 1, 2004
  3. xmlhttprequest not working

    , Sep 21, 2005, in forum: Javascript
    Replies:
    4
    Views:
    152
  4. Replies:
    1
    Views:
    105
    Laurent Bugnion
    Jun 9, 2006
  5. Replies:
    6
    Views:
    309
Loading...

Share This Page