473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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
Jul 23 '05 #1
2 1436


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.respo nseText));
}
};
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/
Jul 23 '05 #2
Thanks, it helped!
On Mon, 07 Feb 2005 19:03:39 +0100, Martin Honnen <ma*******@yahoo.de>
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.respo nseText));
}
};
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
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: dx27s | last post by:
Hi all, I'm working with the XMLHttpRequest object. I receive the following error message: "Permission denied to call method XMLHttpRequest.open" This occurs in Firefox only. IE works fine. ...
20
by: chris.schwalm | last post by:
This is part II of this <a...
25
by: Matt Kruse | last post by:
According to HTTP/1.1 specs, a client should only have two connections open to the host at a time (which can be changed by browser users, of course). When using xmlHttpRequest connections, is...
1
by: 4levels | last post by:
Dear Folks, I stumbled upon a strange behaviour of the XMLHttpRequest.. Maybe I'm just not well informed enough about its possibilities, so could someone please confirm my question? When I...
13
by: TLaufenberg | last post by:
I'm new to Javascript programming and I've run into a bit of a snag with making an XMLHttpRequest in the Safari browser. Actually, the request doesn't work in Firefox either but only when I use a...
1
by: vocalise | last post by:
The title probably isn't very clear, but I haven't been able to find this problem (or I must be having problems figuring out which search strings to use) so I apologize if this has been addressed...
3
by: perrog | last post by:
Hi! What is the expected behaviour when you send an XmlHttpRequest just before the page is about to unload? I'm sending a XmlHttpRequest on an onClick event, and I can inspect that the request...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
6
by: Patrick Nolan | last post by:
I'm working on cross-platform portability of some javascript. My Macintosh testing platform is rather old. It has Safari 1.3.2 and Internet Explorer 5.2. I got Safari working, but now IE is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.