DOMParser Vs ResponseXML?
Feb 24, 2009
In processing the response from an AJAX call, assume the returned xml string as:
"<?xml version="1.0" encoding="UTF-8"?>
<options>
<option text="new search..." value="search..."/>[code].....
Now, in the javascript:
1)If I use ajaxRequest.responseXML, I can directly use it as DOM document, such as: ajaxRequest.responseXML.getElemetnByTagName("option");
2) Or, I can use another way(assume on Firefox):
var parser=new DOMParser();
doc=parser.parseFromString(ajaxRequest.responseText,"text/xml");
doc.getElemetnByTagName("option");
My questions are.Since I can use ajaxRequest.responseXML.getElemetnByTagName("option") directly, I do not need DOMParser to convert.On the other hand, if the ajaxRequest.responseText is NOT of the XML format, the parser.parseFromString will not work any way.Then, why (under what circumstance) should one use DOMParser?
View 1 Replies
Jul 23, 2005
I recently found out that the below code works in FireFox 1.0.4.
str = "<b>Hello world!!!</b>";
var doc = new DOMParser().parseFromString(str, "text/xml");
document.getElementById("div1").appendChild(doc.documentElement);
I knew how to manipulate document object. Now, I see that there is this
DOMParser object that one can use in the browser in Javascript.
What other objects are accessible in FireFox?
I went to www.w3.org and searched for DOMParser and did not find
parseFromString as one of its method.
Where can I find about DOMParser and objects available in the browser.
View 2 Replies
View Related
Aug 18, 2006
I'm having trouble figuring out what's going on with IE6's
Msxml2.XMLHTTP object. I have two feed addresses in this stripped down
version of my code below. Both work fine in Firefox (using the
XMLHttpRequest object), but only the thinkgeek one works in IE. In the
processFeed function, it shows the problem - the first alert shows 0
for the wikihow feed in IE, though it can still display the
responseText. Any insight? Code:
View 6 Replies
View Related
Apr 25, 2010
I'm trying to create a function that will return the value of responseXML so I can assign a variable to it.
Code:
ajax.downloadXml = function (url)
{
var XMLHttpRequestObject = false;
[code]....
Stepping through the function, the onreadystatechange seems to never be executed, so nothing is returned. There's probably just a fundamental I'm messing up on.
View 5 Replies
View Related
Jul 12, 2011
I'm not getting any response for the following ajax request. I'm getting the following error when i try to run request_get_xml.html im mozilla firefox:
XML Parsing Error: not well-formed Location: moz-nullprincipal:{d4e6a0fb-93c0-4ef4-82cf-7ccbd5c1e02e} Line Number 4, Column 2:
-<CATALOG>
request_get_xml.html
<script type="text/javascript">
function loadXMLDoc()[code].....
View 1 Replies
View Related
Feb 8, 2009
I am trying to build a very simple Ajax example with JavaScript and PHP. Basically, the goal is to populate a select list with values dependent on the selection in another list. I am able to do a GET from a server-side script and I see the XML displayed correctly in XMLHttpRequest.responseText. However, when I try to check XMLHttpRequest.responseXML, I am not able to get anything out of it. The alert() shows it as an "Object", so it's not null. I have tried getElementByTagName() from both responseXML and responseXML.documentElement, each time giving a legitimate inner tag, but nothing comes out. What is the correct way of doing it? This is my JavaScript and HTML code:
[Code]...
View 2 Replies
View Related
Jul 23, 2005
I tried POSTing from XMLHttpRequest, i can get the XML right on server
but responseXML from server is coming null. I can see the XML right in
responseText. but responseXML is null. responseText to DOM conversion
also fails while the XML in responseText seems valid ..
-- here is the javascript code for sending ---
View 4 Replies
View Related
Dec 4, 2006
I have several functions with code along the lines of:
var xmlDoc = requestXML("ajax.asp?SP=SelectRelatedTags&tag=" +
array[i]);
The requestXML() function includes the code:
var xmlDoc = null;
http_request.onreadystatechange = function() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
xmlDoc = http_request.responseXML;
} else {
alert('There was a problem with the request.' +
http_request.status);
}}};
http_request.open('GET', url, true);
http_request.send(null);
return xmlDoc;
However, the last line (the return) executes before the readyState
reaches 4. How do I return the xmlDoc to the functions only once the
xmlDoc has been assigned? I tried putting the return statement in a
while loop with the condition that the readyState must = 4 - this
worked, but makes the browser popup a message saying the script is
slowing down the system.
View 1 Replies
View Related
Jul 23, 2005
The situation is; I receive a response back from the server which i only a part of html code. e.g. a table like <table <tr><td>high</td></tr>........ </table>. In other words, I receive
file as a response which has a part of html file.
My aim is to replace an existing document node with the new response.
If I run the following lines (JavaScript):
var parsedText = document.createTextNode(req.responseText);
body.replaceChild(parsedText, toReplace)
It replaces the node 'toReplace' with html codes with the tags include which is not what I want. The html tags are not wanted but should display in correct format as specified by html (a tabular form if htm tag is <table>)
If I try:
View 4 Replies
View Related
Aug 10, 2010
My code gives me an error only the first time when i press the checkbox. If i press it for the second time or just to uncheck the checkbox and it gives me the right answer.I use IE7, xampp with appache server and Windows7.
Message: 'null' is null or not an object
Line: 76
Char: 3
Code: 0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>[code]............
View 1 Replies
View Related
Dec 29, 2010
Im developing a JSP site... my user information validation page is not working and its giving that responseXML object is null...Im not using any XML file to fill the data here.... all the messages custom messages are loaded from the JSP page....My Valildation.js file as below.....
// holds an instance of XMLHttpRequest
var xmlHttp = createXmlHttpRequestObject();
// holds the remote server address[code].....
View 1 Replies
View Related
Jun 10, 2011
I have tried debugging using the alert function and have come to the conclusion that the responseXML property keeps returning null even though I have set everything correctly.
Here is the source code:
HTML Code:
View 4 Replies
View Related
Feb 2, 2006
Doesn't "prototype.js" support the "responseXML" property of the XMLHttpRequest object?
View 2 Replies
View Related