473,785 Members | 2,275 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1463


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.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
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Thanks, it helped!
On Mon, 07 Feb 2005 19:03:39 +0100, Martin Honnen <ma*******@yaho o.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.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.


--
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
6538
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. From my research so far, it seems like this is a security issue related to the fact that I am trying to access a url on a second server. Both servers are under my control, however. Is there a way to get around this
20
2695
by: chris.schwalm | last post by:
This is part II of this <a href="http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/cd54951e0ea277de/639c67f2f7cadb1f?tvc=2&q=Simple+HTML+read%2Fwrite+question#639c67f2f7cadb1f"> post</a>. I am creating a java script that bascially reads a webpage - forwards it to an external program/parser/servlet - then overwrites the webpage with a slightly modify version. Basically I have two questions: (1) Do I need to set my...
25
11300
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 there any way to detect that the request is queued? I did some tests (see "Queued Requests" at http://www.ajaxtoolbox.com/request/examples.php ) and it looks like readyState 1 is fired immediately after the request is made, even though it's not...
1
2193
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 put plain javscript in a file that is read-in through a XMLHttpRequest-object, it's like it is totally ignored. Eg. I have the file ajax_include.html with in it's body the following lines <script type="text/javascript" language="javascript">
13
11503
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 Mac computer. IE and FireFox on a Windows based system works just fine. The problem I am having is that the XMLHttpRequest doesn't open the site that I've programmed into it. When I check the readyState it only returns 0 and never goes through the...
1
7708
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 before, and I apologize if this is the wrong forum since I'm trying to use the XMLHTTPRequest with Javascript and PHP and I couldn't figure out which category my problem belonged to. I am completely new to AJAX and rusty with Javascript. I created a...
3
7087
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 is sent and responded in the network traffic, but my onReadyStateChange handler is notified with an error. It took me some time to deduce what the real problem was, and I think my browser begins to tear down the XmlHttpRequest when the page is
1
4033
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 technology is implemented on more sites now than ever. Compatibility is no longer an issue (IE, Mozilla and Opera all support it), and the benefits to using it are amazing. There are too many PHP programmers avoiding any
6
2306
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 causing trouble. It chokes on this: if (window.XMLHttpRequest) nameReq = new XMLHttpRequest(); else if (window.ActiveXObject) nameReq = new ActiveXObject("Microsoft.XMLHTTP");
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10162
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.