joebednarz
Programmer
I have been trying so many things I'm not sure what I have tried and what I have not. Here is my code:
My XML file that is generated from the "inet.xml_get" call looks like this:
My problem is that if I view the page in IE, I get results. In Firefox or Mozilla, nothing is returned. Any idea what I am doing wrong? I assume the Mozilla doesn't like the ".text" property of the item element, but I can't seem to find anything that works. Some example stuff I've seen uses "nodeValue", but there is never anything populated in that property...
Thanks in advance for your help!
Code:
<html>
<head>
<script type="text/javascript">
var xmlhttp;
var xmlDoc;
var xmlRec = 0;
function loadXMLDoc(start_p)
{
if (window.XMLHttpRequest) // code for Mozilla, etc.
{
xmlhttp=new XMLHttpRequest();
xmlhttp.setRequestHeader("Cache-Control", "no-cache");
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET","inet.xml_get?start_row_p="+start_p,true);
xmlhttp.send(null);
}
else if (window.ActiveXObject) // code for IE
{
try {
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp)
{
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET","inet.xml_get?start_row_p="+start_p,true);
xmlhttp.send();
}
}
if (start_p<=0) { xmlRec = 0; }
else { xmlRec = start_p; }
}
function state_Change()
{
if (xmlhttp.readyState==4) // state==4 means loaded OK
{
if (xmlhttp.status==200) // http status code 200 means loaded fine
{
xmlDoc = xmlhttp.responseXML;
xmlItem = xmlDoc.getElementsByTagName( "ROW" )[0];
document.getElementById("A0").innerHTML=xmlItem.firstChild.nodeValue;
document.getElementById("A1").innerHTML=xmlItem.getElementsByTagName( "LINK_DATE" )[0].text;
document.getElementById("A2").innerHTML=xmlItem.getElementsByTagName( "IP_ADDRESS" )[0].text;
document.getElementById("A3").innerHTML=xmlItem.getElementsByTagName( "BROWSER" )[0].text;
}
else
{
alert("Problem retrieving XML data:" + xmlhttp.statusText);
}
}
}
</script>
</head>
<body onload="loadXMLDoc(xmlRec)">
<h2>Using the HttpRequest Object</h2>
<p><b>History ID</b>
<span id="A0"></span>
</p>
<p><b>Link Date</b>
<span id="A1"></span>
</p>
<p><b>IP Address</b>
<span id="A2"></span>
</p>
<p><b>Browser</b>
<span id="A3"></span>
</p>
<a href="#" onClick="javascript:loadXMLDoc(xmlRec-1)">Prev</a>
<a href="#" onClick="javascript:loadXMLDoc(xmlRec+1)">Next</a>
</body>
</html>
My XML file that is generated from the "inet.xml_get" call looks like this:
Code:
<ROWSET>
<ROW>
<HISTORY_ID>1142453</HISTORY_ID>
<LINK_DATE>12-AUG-02</LINK_DATE>
<NODE_MAP_ID>522320</NODE_MAP_ID>
<PERSON_ID>4005</PERSON_ID>
<IP_ADDRESS>137.240.227.231</IP_ADDRESS>
<BROWSER>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461)</BROWSER>
</ROW>
<ROW>
<HISTORY_ID>1142454</HISTORY_ID>
<LINK_DATE>12-AUG-02</LINK_DATE>
<NODE_MAP_ID>522320</NODE_MAP_ID>
<PERSON_ID>4005</PERSON_ID>
<IP_ADDRESS>137.240.227.231</IP_ADDRESS>
<BROWSER>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461)</BROWSER>
</ROW>
</ROWSET>
My problem is that if I view the page in IE, I get results. In Firefox or Mozilla, nothing is returned. Any idea what I am doing wrong? I assume the Mozilla doesn't like the ".text" property of the item element, but I can't seem to find anything that works. Some example stuff I've seen uses "nodeValue", but there is never anything populated in that property...
Thanks in advance for your help!