Jump to content

Problems with xmlhttp.responseXML object


ellitigg

Recommended Posts

Hi, I hope someone can help. I've had a look through the other threads and I can't see anything on this...

I've been playing with AJAX and successfully got my code working on one server but now I've migrated it to another server (all paths have been updated!) and the same code doesn't work.

The basics are...

The Javascript:
[code] 
...
xmlhttp.open('POST', '../tools/displayCalEvents.php', true);

  /* The callback function */
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4) {
      if (xmlhttp.status == 200) {
        if(xmlhttp.responseXML) {
          [color=red]alert (xmlhttp.responseXML.getElementsByTagName('title')[0].firstChild.data);[/color]
          displayPopup(xmlhttp.responseXML);
        } else if(xmlhttp.responseXml) {
          alert(xmlhttp.responseXml.getElementsByTagName('title')[0].firstChild.data);
          displayPopup(xmlhttp.responseXml);
        }
      }
    }
  }
...
[/code]

The PHP:
[code]
<?
header('Content-Type: text/xml');
$res = '<?xml version="1.0" encoding="utf-8"?><xmlresponse><title>Test Meeting</title></xmlresponse>';
echo ($res);
?>
[/code]

The alerts are just in there for debugging. The readyState is correctly getting to '4' and the status to '200' but I am getting a Javascript error against the line marked in red saying that an object is required. It seems like the responseXML object is not being returned from the PHP file.

Can anyone help? I really appreciate any responses!

Many thanks,

Elli
Link to comment
https://forums.phpfreaks.com/topic/26322-problems-with-xmlhttpresponsexml-object/
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.