responseXML not working
Hi guys,
I've been stuck on this problem now for 2 days. It seems to be a common problem from searching on forums, but none of the suggestions has worked for me.
I am requesting a document - fakeresponse.xml, but it is not returned in the responseXML - instead it is returned in responseText.
Here is my xml (i have used an online validator - it is fine):
[code]
<?xml version="1.0"?>
<markers>
<marker address="50 Kent Street" lat="-33.7670673" lng="150.9679327"/>
<marker address="27 Acland Street" lat="-33.5621071" lng="149.8561493"/>
<marker address="19 Riley Street" lat="-33.8534749" lng="142.1672888"/>
</markers>
[code]
and in javascript :
[CODE]
var xmlhttp=false;
var xmldoc;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp=false;
}
}
function getMarkers()
{
xmlhttp.open("GET", "fakeresponse.xml", false);
xmlHttp.setRequestHeader("Content-Type", "text/xml");
xmlhttp.overrideMimeType('text/xml');
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4)
{
xmldoc = xmlhttp.responseXML;
//xmldoc = xmlhttp.responseText;
alert(xmldoc); // This will not execute for responseXML, but will for responseText
var xarray = xmldoc.documentElement.childNodes;
alert(xarray[i]);
}
}
xmlhttp.send(null);
}
[CODE]
Can anybody please spot what I am missing? Can jquery offer a better solution?
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks