Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Newbie to XML - problem using xmlhttp

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 6/4/2007 4:16:00 PM

Tim Platt wrote:
> Until now I have not had any reason to learn about XML. I have spent
> quite a few hours playing with examples and reading group discussions
> like these - with a certain amount of success. However, I have a
> specific task to accomplish, and so far I have fallen at the last
> hurdle.
> 
> I want to display the following 'feed' from an external server on our
> clients:
> 
> 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

Inside of the browser your script can only connect back to the server 
the HTML document with the script was loaded from.

>   xmlhttp.onreadystatechange=onResponse;
>   xmlhttp.open("GET",url,true);
>   xmlhttp.setRequestHeader("Content-Type","text/xml")
>   xmlhttp.send(null);

The HTTP reqest header Content-Type should be set if you do a POST or 
PUT request and send a request body. As you do a GET request which does 
not have any request body it does not make sense to set the Content-Type 
request header.


>   document.getElementById('A1').innerHTML=xmlhttp.status;
>   document.getElementById('A2').innerHTML=xmlhttp.statustext;
>   document.getElementById('A3').innerHTML=xmlhttp.responsetext;

JavaScript is case sensitive so it should be statusText and responseText.

>   var response = xmlhttp.responseXML.documentElement;

For responseXML to be populated the response the server sends should 
have Content-Type application/xml or text/xml but that server does not 
send that header value so responseXML is not being populated.






-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent