Link to home
Start Free TrialLog in
Avatar of MikeCombe
MikeCombeFlag for United States of America

asked on

javascript request.responseXML

Using alert I can see "textDoc" but NOT "xmlDoc"
Does this mean I am not getting an xml document returned in "request.responseXML"
request = createRequest();
 request.open("GET", "http://www.AmericanMarketingGroup.net/ws/get_date_time.asp", false);
 request.send(null);
 if (request.readyState == 4) {
if (request.status == 200) {
var responseDoc = request.responseXML;
var textDoc = request.responseText;			
var xmlDoc = responseDoc;
alert("Status:"+request.status+"\nText Length:"+textDoc.length+"\nText:"+textDoc+"\nXML Length:"+xmlDoc.length+"\nXML:"+xmlDoc);

Open in new window

Avatar of AsishRaj
AsishRaj
Flag of Fiji image

Avatar of MikeCombe

ASKER

sorry....all four points we evaluated but was not the problrm.
anything else ?
Avatar of laurent_roy
laurent_roy

no the first point is not validated !
You have to add an http header : "Content-Type:text/xml"
yes I did that already...the original code snipet doen't show it. I tried it both ways, with & without it.
Below is the Revised code snippet.


= = = = = = = Revised code snippet = = = = = 
 
request = createRequest();
request.open("GET", "http://www.AmericanMarketingGroup.net/ws/get_date_time.asp", false);
request.setRequestHeader("Content-Type", "text/xml");
request.send(null);
if (request.readyState == 4) {
if (request.status == 200) {
var responseDoc = request.responseXML;
var textDoc = request.responseText;			
var xmlDoc = responseDoc;
alert("Status:"+request.status+"\nText Length:"+textDoc.length+"\nText:"+textDoc+"\nXML Length:"+xmlDoc.length+"\nXML:"+xmlDoc);

Open in new window

making these changes...makes the "xml length" display different values...

var xmlDoc = request.responseXML;                            //<-- xml length=undefined
//var xmlDoc = request.responseXML.xml;      //<-- xml length=0

= = = = = = = Revised code snippet = = = = = 
 
request = createRequest();
request.open("GET", "http://www.AmericanMarketingGroup.net/ws/get_date_time.asp", false);
request.setRequestHeader("Content-Type", "text/xml");
request.send(null);
if (request.readyState == 4) {
if (request.status == 200) {
var responseDoc = request.responseXML;
var textDoc = request.responseText;	
		
var xmlDoc = request.responseXML;	         //<-- xml length=undefined
//var xmlDoc = request.responseXML.xml;	//<-- xml length=0
 
alert("Status:"+request.status+"\nText Length:"+textDoc.length+"\nText:"+textDoc+"\nXML Length:"+xmlDoc.length+"\nXML:"+xmlDoc);

Open in new window

you don't have to put the header in the request but in the response, that is to say in get_date_time.asp.
nope...
put ("Content-Type", "text/xml") into the header of the generating xml page....same response as before.
ASKER CERTIFIED SOLUTION
Avatar of MikeCombe
MikeCombe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
self-discovered