473,486 Members | 2,429 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Loading HTML using xmlhttprequest( )

I am trying to build a site using xmlhttprequest, so that the browser
never reloads. I want to pass the HTML info of the "navigation column"
, "content column" as a XML page from the server.
From the help on the net, I have managed to use xmlhhtprequest

succesfully to get the file from server and parse the XML. But I dont
know how to display the HTML info on the page.

When I just add the parsed HTML content from the xml to a <div>, it
just displays the text as HTML but not with the formating. ie the
display i get is " < b >this has to be in bold </ b > "

Can someone help me with this. How do I display it as formatted text.
Has it got anything to do with WYSIWYG.

Thanks in advance for the help.

Aug 8 '05 #1
2 2191


Arun wrote:
I am trying to build a site using xmlhttprequest, so that the browser
never reloads. I want to pass the HTML info of the "navigation column"
, "content column" as a XML page from the server.
From the help on the net, I have managed to use xmlhhtprequest

succesfully to get the file from server and parse the XML. But I dont
know how to display the HTML info on the page.

When I just add the parsed HTML content from the xml to a <div>, it
just displays the text as HTML but not with the formating. ie the
display i get is " < b >this has to be in bold </ b > "


Judging from that description it sounds as if you are best served with a
library taking care of that stuff so you might want to look into
libraries like Sarissa
<http://sarissa.sourceforge.net/>

As for your problem you haven't provided any code so I can only guess
that you are using the responseText you receive but then try to add it
to an element as a text node e.g.
someElement.appendChild(document.createTextNode(ht tpRequest.responseText));
as that way you simply create a text node and any markup in responseText
shows up as plain text.

If the responseText contains HTML markup then one rather easy and rather
cross browser way of having it parsed and inserted into the document is
setting the innerHTML property of an element e.g.
someElement.innerHTML = httpRequest.responseText;
If you don't have an element then you can create one e.g.
var div = document.createElement('div');
div.innerHTML = httpRequest.responseText;
document.body.appendChild(div);

There are other ways, at least with Mozilla and with Opera it makes
sense to send XHTML and then simply import nodes from responseXML
instead of using responseText.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 8 '05 #2
Thanks a lot Martin. I will try this out.
innerHTML method seems to be easier than using an API.

Aug 9 '05 #3

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

Similar topics

2
1869
by: hbchai | last post by:
I'm adapting the ajax-like asynchronous request pattern mentioned in this article: http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html?page=2 for my Sudoku...
11
15138
by: paladin.rithe | last post by:
I'm new to AJAX programming (and JavaScript), but I've been picking up the idea pretty quick. I have a question though. With the project that I'm working on, I would like to have the main page...
2
1866
by: www.gerardvignes.com | last post by:
I am using this to load the client JavaScript for a web application when it is selected by the user) via an Ajax connection to the server. I have found only two ways of loading new JavaScript...
6
2736
by: Venkatesh | last post by:
Hello All, I have couple of doubts regarding the concept of on-demand javascript loading using javascript code. I could see on the net different techniques for achieving this - techniques like:...
13
2482
by: mowsen | last post by:
Hello Group, i'm using a little "ajax" loader script to dynamically load files into different "div" tags on my main site. the code for this part looks like: function loader() { var args =...
5
38980
by: chakradhari.ashish | last post by:
Does anybody know how can I load an html page inside a <div</div> where the content gets update on the onclick even of anchor <a href=> </a>? I googled around and followed some links pointing me...
6
10907
by: Shigun | last post by:
On a website I am working on I am trying to load another page into a div on the the page the user does his work from. What I have works correctly in FireFox, but not in IE. I've rummaged Google for...
20
3993
RMWChaos
by: RMWChaos | last post by:
Currently testing in: WinVista / IE7 I have been working on getting xmlhttprequest going for weeks now. I have finally gotten a semi-working script going. Pulling up text or xml files works great...
0
6967
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...
0
7132
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,...
1
6846
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...
0
7341
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
5439
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,...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
266
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...

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.