Jump to content

I can't figure out why this isnt working...


Mateobus

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.