473,396 Members | 1,785 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,396 software developers and data experts.

Howto access xmlHttp.responseText as document.getElementByTagName, etc...

Howto access xmlHttp.responseText as document.getElementByTagName ?

If I access a .html page through the xmlHttp, how can I use the functions .getElementsByTagName and .getElementById on the data found in the xmlHttp.responseText?

(the .responseXML returns null, and the responseText is simple text, of course containing valid html code)
Jun 21 '07 #1
5 7133
acoder
16,027 Expert Mod 8TB
Either have valid XML or you could add it to the document e.g. a hidden div and then parse it.
Jun 21 '07 #2
ronnil
134 Expert 100+
Howto access xmlHttp.responseText as document.getElementByTagName ?

If I access a .html page through the xmlHttp, how can I use the functions .getElementsByTagName and .getElementById on the data found in the xmlHttp.responseText?

(the .responseXML returns null, and the responseText is simple text, of course containing valid html code)
What I'm reading:

You want to download an html page via xmlHttp, the elements inside that that downloaded html page you want to access via document.getElementByID

right?

This is not doable, per say, since you don't download htmlpages with htmlHttp but you download data, either in string or xml.

What i think acoder means is:

you make an empty div tag.
you download your htmlpage and retrieve it with the responseText property.
you then set your div tag's innerHTML=responseText

now, for browser compability reasons i suggest you use an iframe instead of a div tag :) for example, if your html page is valid xhtml you will have header and such defined, that could make browsers confused... this won't happen in an iframe ;)
Jun 21 '07 #3
Actually I wanted to download a html template and an xml file and combine them in the browser :P I don't know if this is a good idea, but I guess it could be done.

Now I need to mostly replace the actual page in the browser with the one downloaded and then fill it wit data from the xml.

Gimme your critics on this idea :)
Jun 21 '07 #4
rnd me
427 Expert 256MB
Actually I wanted to download a html template and an xml file and combine them in the browser :P I don't know if this is a good idea, but I guess it could be done.

Now I need to mostly replace the actual page in the browser with the one downloaded and then fill it wit data from the xml.

Gimme your critics on this idea :)
yes, it is a good idea.
so good that there is already a major system for doing just that:
XSLT.

think of it as CSS on steroids.

you can not only apply html styles to the xml data, but you can sort, filter, modify, combine severy files, etc.

be sure read up on it, it sound like it would be right up your alley.
Jun 21 '07 #5
acoder
16,027 Expert Mod 8TB
What i think acoder means is:

you make an empty div tag.
you download your htmlpage and retrieve it with the responseText property.
you then set your div tag's innerHTML=responseText
Yes, that's right.
now, for browser compability reasons i suggest you use an iframe instead of a div tag :) for example, if your html page is valid xhtml you will have header and such defined, that could make browsers confused... this won't happen in an iframe ;)
Yes, that's a better solution. Thanks!
Jun 22 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jason Morehouse | last post by:
Hello, Anyone know if it's possible to speak with the server via xmlhttp.open while the browser is doing a post -- file upload in this case: <form enctype="multipart/form-data"...
9
by: fochie | last post by:
Greetings, I'm having a problem when I try to GET a file from my server via xmlhttp when using Mozilla. With IE I can get any type of file fine, get/display headers fine, etc. With Mozilla,...
8
by: Marcos | last post by:
Hello, Is possible to determine the timeout of XMLHTTP Request? My solicitations using the XMLHTTP they are giving error and this because the page it is delaying a little more to send the...
5
by: hatsumoto | last post by:
Hello, I create an ActiveXObject("Msxml2.XMLHTTP") from my HTML page to submit (i.e. post) XML to a server. I can see the content of the XML response via javascript alert(xmlhttp.responseText)....
3
by: SM | last post by:
Hello, Im trying to access elements in my XML file using the JavaScript DOM but i'm not sure how. I use AJAX to access the XML and then use the responseXML property to access the XML file data. I...
1
by: farghal | last post by:
Hello as many people I'm new to ajax but trying my best to understand. At this point I got a problem I'm not able to solve. I've looked on several forums and googled internet but I can't find a...
3
by: Andrewh | last post by:
Hi, I am having a bit of a problem with using xmlhttp. The code of the javascript file is shown below used in Windows XP. var xmlhttp = null; function SetURLDiv(url) { if...
21
vikas251074
by: vikas251074 | last post by:
I am getting error while entry in userid field. When user enter his user id, an event is fired immediately and user id is verified using AJAX method. But I am getting error 'Object doesn't support...
2
by: trpost | last post by:
Is it possible to execute javascript as passed in xmlHttp.responseText Here is what I am doing: search.js var xmlHttp xmlHttp=GetXmlHttpObject() var url="search.php"...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...
0
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
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
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,...

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.