Mateobus Posted April 10, 2007 Share Posted April 10, 2007 The error in the firefox console is: request.responseXML has no properties. This leads me to believe that my xml is not valid. I do know that the file is reaching the server though. Here is my code... var request = new XMLHttpRequest(); request.open("POST", "script.php", true); request.onreadystatechange = function() { if (request.readyState == 4) { if (request.status == 200) { document.getElementById('status').firstChild.data = request.responseXML.documentElement.getElementsByTagName("compname")[0].childNodes[0].nodeValue; }else { document.getElementById('status').firstChild.data ="The server was unable to process your request"; } } }; request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); request.setRequestHeader("Content-length", 17); request.setRequestHeader("Connection", "close"); request.send(qs); and the script.php file is just this: $RETURN_XML = "<?xml version='1.0' encoding='ISO-8859-1'?>"; $RETURN_XML .= "<company>"; $RETURN_XML .= "<compname>asdf</compname>"; $RETURN_XML .= "<contname>asfd</contname>"; $RETURN_XML .= "<address>asdf</address>"; $RETURN_XML .= "<city>asdfff</city>"; $RETURN_XML .= "<country>asdfff</country>"; $RETURN_XML .= "</company>"; echo $RETURN_XML; Any help is appreciated here...thanks a bunch. Link to comment https://forums.phpfreaks.com/topic/46363-i-cant-figure-out-why-this-isnt-working/ Share on other sites More sharing options...
Glyde Posted April 11, 2007 Share Posted April 11, 2007 The content-type header from the PHP file MUST be either text/xml or application/xml I believe. Try adding: header("Content-type: text/xml"); To the top of the PHP script and see if that solves the problem. Link to comment https://forums.phpfreaks.com/topic/46363-i-cant-figure-out-why-this-isnt-working/#findComment-226505 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.