XMLHTTP - null is null or not an object



I would be very grateful if someone could assist me. I am relatively
new to httpxml and xml in general. I have done a lot of research and
tried lots of examples, most of which I can get working.

I am trying to send a request to a server for some vehicle data, which
I then want to display.

I have the following code. If I set the loadXMLDoc to an XML file on
the client it works fine. There is obviously a gap in my understanding
- why can I not get this to work? Any help greatly appreciated.

<html>
<head>
<script type="text/javascript">
var xmlhttp

function loadXMLDoc(url)
{
xmlhttp=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest()
}
// code for IE
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=onResponse;
xmlhttp.open("GET",url,true);
xmlhttp.setRequestHeader("Content-Type","text/xml")
xmlhttp.send(null);
}
else
{
alert("Your browser does not support XMLHTTP.")
}
}

function checkReadyState(obj)
{
if(obj.readyState == 4)
{
if(obj.status == 200)
{
return true;
}
else
{
alert("Problem retrieving XML data");
}
}
}

function onResponse()
{
if(checkReadyState(xmlhttp))
{
document.getElementById('A1').innerHTML=xmlhttp.status;
document.getElementById('A2').innerHTML=xmlhttp.statustext;
document.getElementById('A3').innerHTML=xmlhttp.responsetext;
var response = xmlhttp.responseXML.documentElement;

document.getElementById('A4').innerHTML=response.getElementsByTagName("Model")
[0].firstChild.data;
}
}
</script>
</head>

<body onLoad="loadXMLDoc('http://www.q3.hpi.co.uk/servlet/HpiGate1_0?
forward=YES&efxid=0502863&password=testing&initials=tp&function=SEARCH&vrm=V110ABE&XML=YES&product=HPI11&deviceType=XM');">

<p><b>status:</b>
<span id="A1"></span>
</p>

<p><b>status text:</b>
<span id="A2"></span>
</p>

<p><b>response:</b>
<span id="A3"></span>
</p>

<p><b>Model:</b>
<br><span id="A4"></span>
</p>

</body>

.



Relevant Pages

  • Extending Active Directory using Attributes and XML
    ... Basically I have an internal web application written in ASP.NET/C#. ... XML doc). ... a custom dialog in the Active Directory MSC. ... Thank you in advance for any help/advice given I am most grateful. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Newbie Question: CSV to XML
    ... script that I wrote to convert CSV to XML. ... I'll happily admit that I still have a lot to learn about Python so I'm always grateful for constructive feedback. ...
    (comp.lang.python)
  • XML SQL Server 2000
    ... I'm a complete newbie to XML. ... I would be very grateful if anyone could point me in the ... My approach towards this was to create a trigger in SQL Server that ... would produce an XML document based on an SQL query. ...
    (microsoft.public.sqlserver.xml)
  • Re: Reading XML Via Delphi 6 App?
    ... I am still grateful to my former boss for wanting me to *write* an XML ...
    (comp.lang.pascal.delphi.misc)
  • Re: Saving Excel 2000 files as .xml
    ... I would really be very grateful if ... > some one will take the time to answer this query in detail. ... Excel 2000 does not support the XML format. ... hit me in the face if it doesn't. ...
    (microsoft.public.excel.programming)