Jump to content

keeps saying my i have no properties...


monkotronic

Recommended Posts

i'm doing an XMLHttpRequest.  it fetches just fine.  when i dump the responseText into my innerhtml, it is fine.  that was just for testing.  i wanted to assign my responseXML to a variable called areaXML.  my code:

-----------------------------------------------------------------------

function handleStateChange() {

if(theXML.readyState ==4) {

if(theXML.status == 200) {

areaXML = theXML.responseXML;

}

}

}

-------------------------------------------------------------------------

but when i:

 

theDates =areaXML.getElementsByTagName("date");

 

i get:

 

Error: areaXML has no properties

Source File: http://voodoo/sfv/javascript/pajax.js

Line: 63

 

i cant figure out why!  the file exists, it reads it.  if i dump the responseText instead of responseXML it is ok.  if i dump the responseXML, it tells me it is an XMLDocument object so that seems ok.  areaXML is declared in the global space so that should be ok.

 

what could i be missing? ???

Link to comment
Share on other sites

i dont think so since areaXML is declared at the top of the script in the global space, not inside any function.  it seems it must be along those lines, though, cause everything is checking out for filling the variable.  is there a special way of declaring a global that i'm missing? ???

Link to comment
Share on other sites

are you using something like var areaXML = ''; ?

 

If you're pretty sure its a scope issue, you could also attach it to the document with something like this:

document.areaXML = '';

 

function handleStateChange()

...

  document.areaXML = theXML.responseXML;

Link to comment
Share on other sites

here is more detail (the error, the html file, the xml file)...

 

opera throws this error (more detail than firefox):

Event thread: load

Error:

 

name: TypeError

 

message: Statement on line 32: Could not convert undefined or null to object

Backtrace:

  Line 32 of inline#1 script in http://voodoo/sfv/testxml.html

 

    var Listing = areaXML.getElementsByTagName("time");

  Line 1 of  script

 

    testrun();

______________________________________________________________

here is the html file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

 

<head>

  <title>asdf</title>

<script >

var theXML;

var areaXML;

 

function createXMLHttpRequest() {

if (window.ActiveXObject) {

theXML = new ActiveXObject("Microsoft.XMLHTTP");

}

else if (window.XMLHttpRequest) {

theXML = new XMLHttpRequest();

}

}

 

function startRequest() {

var dataFile='content/monthlycalendar.xml';

createXMLHttpRequest();

theXML.onreadystatechange = handleStateChange;

theXML.open("GET", dataFile, true);

theXML.send(null);

}

 

function handleStateChange() {

if(theXML.readyState ==4) {

if(theXML.status == 200) {

areaXML = theXML.responseXML;

}

}

}

 

function testrun() {

startRequest();

var Listing = areaXML.getElementsByTagName("time");

document.getElementById("bigone").innerHTML = Listing[0].childNodes[0].nodeValue;

}

</script>

</head>

<body onload="testrun();">

<DIV align="center" id="bigone">nothinhere</DIV>

</body>

</html>

---------------------------------------------------------------------------------------------------------------

here is the xml file being called:

 

<?xml version="1.0"?>

<!DOCTYPE area [

  <!ELEMENT area (subarea)>

  <!ATTLIST area name CDATA " ">

  <!ELEMENT subarea (event)>

  <!ATTLIST subarea name CDATA " ">

  <!ATTLIST subarea title CDATA " ">

  <!ELEMENT event (date, time, type, topic, notes, location)>

  <!ELEMENT date (#PCDATA)>

  <!ELEMENT time (#PCDATA)>

  <!ELEMENT type (#PCDATA)>

  <!ELEMENT topic (#PCDATA)>

  <!ELEMENT notes (#PCDATA)>

  <!ELEMENT location (#PCDATA)>

]>

<area name="monthlycalendar">

<subarea name="events" title="On the Schedule">

          <event>

<date>2007,2,7</date>

<time>8PM</time>

            <type>lecture</type>

                  <topic>The Call of the Wild</topic>

                  <notes></notes>

                  <location>Old Temple</location>

            </event>

            <event>

<date>2007,2,14</date>

<time>8PM</time>

                    <type>lecture</type>

                  <topic>Mom is On The Phone</topic>

                  <notes></notes>

                  <location>New Temple</location>

            </event>

</subarea>

</area>

Link to comment
Share on other sites

is there a way to actually see what is being stored into theXML.responseXML?  if i use responseText instead, i get a dump of my file minus the markup.  if i dump responseXML, i just get [object:xml document].  but when i try to access this object, that is when the error above gets thrown.  what would cause a text return but no xml return?

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.