473,847 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ 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 2227


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.sourcef orge.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.app endChild(docume nt.createTextNo de(httpRequest. 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.inn erHTML = httpRequest.res ponseText;
If you don't have an element then you can create one e.g.
var div = document.create Element('div');
div.innerHTML = httpRequest.res ponseText;
document.body.a ppendChild(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
1899
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 implementation: http://ttwhy.org/code/mosudoku.html By changing the "src" attribute of a script tag, I can dynamically load
11
15179
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 loaded dynamicly. Right now, it's just a php script that loads the information when it's called. But, I can see some problems cropping up. What I want to do is call the php scripts when the page loads via JavaScript/AJAX. I'm just not sure what...
2
1893
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 after the web page is loaded. 1. Create a new script element (where head is the id of the head tag): var s = document.createElement('script'); s.setAttribute('type','text/javascript'); s.setAttribute('src', 'scripts/myscript.js');
6
2782
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: 1. document.write("<script src= language='JavaScript'></script>); 2. sc = document.createElement("<script>"); sc.setAttribute("src", ); and append this to the head
13
2545
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 = loader.arguments; switch (args) { case
5
39017
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 that it is possible to use javascript combined with CSS for doing this? Any ideas? Chakra
6
10928
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 quite a bit and found similar problems, but no actual solutions. Here is the JavaScript I have to load a URL into a Div: function setResponseHtml(pUrl, pDiv) { var lHttp = getHTTPObjectHtml(); var lUrl = pUrl; lUrl =...
20
4069
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 and populates into the webpage; however, executing javascript has a few problems: 1. Opens on a blank page, but not a new page. It appears to compeltely overwrite the original page. I want it to update the existing page by loading within a <div>...
0
9879
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
10981
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10643
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
10706
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
10330
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
9477
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...
1
7879
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4521
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 we have to send another system
2
4113
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.