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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.