473,734 Members | 2,824 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"No Properties" error... can't navigate dom elements. Please help...

hi.

for some reason i am not able to navigate the dom.
i keep getting the 'no properties' error but i think i
am doing everything right. this is an XML response
from an AJAX call.

The ajax method to call the server code looks like this.
i am passing a cookie as a parameter:

Code:

var stockquote = get_cookie("sto ckquote");
ajaxSend('GET', 'data.aspx',sto ckquote, dataResponseHan dler, false);

the code coming from the server looks like this:

Code:

Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

Dim con As System.Data.Sql Client.SqlConne ction = New
System.Data.Sql Client.SqlConne ction(connectio n stuff...)
Dim editcriteriacmd As System.Data.Sql Client.SqlComma nd = New
Data.SqlClient. SqlCommand(sele ct statement stuff..., con)

con.Open()

'EDITPROFILE STUFF

Dim edit_dr As Data.SqlClient. SqlDataReader =
editcriteriacmd .ExecuteReader( Data.CommandBeh avior.CloseConn ection)

'main declarations
dim sex as string
dim age_frm as string
dim age_to as string
dim type as string
[SNIP]

If edit_dr.HasRows Then
While edit_dr.Read
sex = edit_dr.Item("s ex").ToString ()
age_frm = edit_dr.Item("a ge1").ToString( )
age_to = edit_dr.Item("a ge2").ToString( )
type = edit_dr.Item("t ype").ToString( )
[SNIP]
End While
End If

edit_dr.Close()

Dim sbhtml As New System.Text.Str ingBuilder

sbhtml.Append(" <?xml version='1.0' encoding='ISO-8859-1'?>")
sbhtml.Append(" <search>")
sbhtml.Append(" <sex>")
sbhtml.Append(s ex.ToString)
sbhtml.Append(" </sex>")
sbhtml.Append(" <agefrom>")
sbhtml.Append(a ge_frm.ToString )
sbhtml.Append(" </agefrom>")
sbhtml.Append(" <ageto>")
sbhtml.Append(a ge_to.ToString)
sbhtml.Append(" </ageto>")
sbhtml.Append(" <type>")
sbhtml.Append(t ype.ToString)
sbhtml.Append(" </type>")
[SNIP]
sbhtml.Append(" </search>")

Context.Respons e.ContentType = "text/xml"
Response.Write( sbhtml.ToString )

End Sub

the response is parsed in the dataResponseHan dler function.

Code:

function dataResponseHan dler(ajaxReques t)

{ //1

// if xmlhttp shows "loaded"
if (ajaxRequest.re adyState==4)

{ //2

// if "OK"
if
(ajaxRequest.st atus==200)

{ //3

try { //4

//UNCOMMENT FOR
ERROR CHECKING - RESPONSETEXT IN NEW WINDOW
//var doc =
ajaxRequest.res ponseText;
//
doc=doc.replace (/</g, '<').replace(/\>/g, '>');

//childWin=window .open("", "childwin") ;

//childWin.docume nt.write("<pre> "+doc+"</pre>");

//childWin.docume nt.close();

var dom =
parse(ajaxReque st.responseText );

var search =
dom.getElements ByTagName('sear ch').item(0);

if (search) {
alert("search has something") } else { alert("search is empty"); }

var sex;
var age_frm;
var age_to;
var type;
[SNIP]

if
(search.getElem entsByTagName(" sex")[0].nodeValue != "") {
sex =
search.getEleme ntsByTagName("s ex")[0].nodeValue;
alert("sex:
"+sex);
}

if
(search.getElem entsByTagName(" age_frm")[0].firstChild.nod eValue != "")
{
age_frm =
search.getEleme ntsByTagName("a ge_frm")[0].firstChild.nod eValue;

alert("agef: "+age_frm);
}

if
(search.getElem entsByTagName(" age_to")[0].firstChild.nod eValue != "") {
age_to =
search.getEleme ntsByTagName("a ge_to")[0].firstChild.nod eValue;

alert("aget: "+age_to);
}

if
(search.getElem entsByTagName(" type")[0].firstChild.nod eValue != "") {
type =
search.getEleme ntsByTagName("t ype")[0].firstChild.nod eValue;

alert("type: "+type);
}

} //4

catch (e) { //5

alert("There has
been an error. The problem is that " + e.message + ". This is a '" +
e.name + "' problem.");

} //5

} //3

else

{ //6
alert("Problem retrieving
XML data")
} //6

} //2

} //1


i am parsing the code using the below parse function:

Code:

function parse(xml) {

var dom;

try {
dom = new
ActiveXObject(" Microsoft.XMLDO M");
dom.async = false;
dom.loadXML(xml );
} catch (error) {
try {
var parser = new
DOMParser();
dom =
parser.parseFro mString(xml, "text/xml");
delete parser;
} catch (error2) {
if (debug)
alert("XML parsing is
not supported.");
}
}

return dom;

}

no matter what i do i keep getting that search has no properties. but
the below line is correct, isn't it?
var search = dom.getElements ByTagName('sear ch').item(0);

so, if that is correct, then the problem is the content of the
response. but, when i uncomment my errorhandling code:

//UNCOMMENT FOR ERROR CHECKING - RESPONSETEXT IN NEW WINDOW
//var doc = ajaxRequest.res ponseText;
// doc=doc.replace (/</g, '<').replace(/\>/g, '>');
//childWin=window .open("", "childwin") ;
//childWin.docume nt.write("<pre> "+doc+"</pre>");
//childWin.docume nt.close();

i get the below line:

<?xml version='1.0'
encoding='ISO-8859-1'?><search><se x>male</sex><agefrom>18 </agefrom><ageto> 100</ageto><type>som etype</type></search>
so, that is everything. i am probably overlooking something obvious
but, at this point, i need another set of eyes to point
it out.

thanks.

Oct 24 '06 #1
1 2773
ok.

i have sorted this out.
i had a spelling error in the XML doc.

pbd22 wrote:
hi.

for some reason i am not able to navigate the dom.
i keep getting the 'no properties' error but i think i
am doing everything right. this is an XML response
from an AJAX call.

The ajax method to call the server code looks like this.
i am passing a cookie as a parameter:

Code:

var stockquote = get_cookie("sto ckquote");
ajaxSend('GET', 'data.aspx',sto ckquote, dataResponseHan dler, false);

the code coming from the server looks like this:

Code:

Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

Dim con As System.Data.Sql Client.SqlConne ction = New
System.Data.Sql Client.SqlConne ction(connectio n stuff...)
Dim editcriteriacmd As System.Data.Sql Client.SqlComma nd = New
Data.SqlClient. SqlCommand(sele ct statement stuff..., con)

con.Open()

'EDITPROFILE STUFF

Dim edit_dr As Data.SqlClient. SqlDataReader =
editcriteriacmd .ExecuteReader( Data.CommandBeh avior.CloseConn ection)

'main declarations
dim sex as string
dim age_frm as string
dim age_to as string
dim type as string
[SNIP]

If edit_dr.HasRows Then
While edit_dr.Read
sex = edit_dr.Item("s ex").ToString ()
age_frm = edit_dr.Item("a ge1").ToString( )
age_to = edit_dr.Item("a ge2").ToString( )
type = edit_dr.Item("t ype").ToString( )
[SNIP]
End While
End If

edit_dr.Close()

Dim sbhtml As New System.Text.Str ingBuilder

sbhtml.Append(" <?xml version='1.0' encoding='ISO-8859-1'?>")
sbhtml.Append(" <search>")
sbhtml.Append(" <sex>")
sbhtml.Append(s ex.ToString)
sbhtml.Append(" </sex>")
sbhtml.Append(" <agefrom>")
sbhtml.Append(a ge_frm.ToString )
sbhtml.Append(" </agefrom>")
sbhtml.Append(" <ageto>")
sbhtml.Append(a ge_to.ToString)
sbhtml.Append(" </ageto>")
sbhtml.Append(" <type>")
sbhtml.Append(t ype.ToString)
sbhtml.Append(" </type>")
[SNIP]
sbhtml.Append(" </search>")

Context.Respons e.ContentType = "text/xml"
Response.Write( sbhtml.ToString )

End Sub

the response is parsed in the dataResponseHan dler function.

Code:

function dataResponseHan dler(ajaxReques t)

{ //1

// if xmlhttp shows "loaded"
if (ajaxRequest.re adyState==4)

{ //2

// if "OK"
if
(ajaxRequest.st atus==200)

{ //3

try { //4

//UNCOMMENT FOR
ERROR CHECKING - RESPONSETEXT IN NEW WINDOW
//var doc =
ajaxRequest.res ponseText;
//
doc=doc.replace (/</g, '<').replace(/\>/g, '>');

//childWin=window .open("", "childwin") ;

//childWin.docume nt.write("<pre> "+doc+"</pre>");

//childWin.docume nt.close();

var dom =
parse(ajaxReque st.responseText );

var search =
dom.getElements ByTagName('sear ch').item(0);

if (search) {
alert("search has something") } else { alert("search is empty"); }

var sex;
var age_frm;
var age_to;
var type;
[SNIP]

if
(search.getElem entsByTagName(" sex")[0].nodeValue != "") {
sex =
search.getEleme ntsByTagName("s ex")[0].nodeValue;
alert("sex:
"+sex);
}

if
(search.getElem entsByTagName(" age_frm")[0].firstChild.nod eValue != "")
{
age_frm =
search.getEleme ntsByTagName("a ge_frm")[0].firstChild.nod eValue;

alert("agef: "+age_frm);
}

if
(search.getElem entsByTagName(" age_to")[0].firstChild.nod eValue != "") {
age_to =
search.getEleme ntsByTagName("a ge_to")[0].firstChild.nod eValue;

alert("aget: "+age_to);
}

if
(search.getElem entsByTagName(" type")[0].firstChild.nod eValue != "") {
type =
search.getEleme ntsByTagName("t ype")[0].firstChild.nod eValue;

alert("type: "+type);
}

} //4

catch (e) { //5

alert("There has
been an error. The problem is that " + e.message + ". This is a '" +
e.name + "' problem.");

} //5

} //3

else

{ //6
alert("Problem retrieving
XML data")
} //6

} //2

} //1


i am parsing the code using the below parse function:

Code:

function parse(xml) {

var dom;

try {
dom = new
ActiveXObject(" Microsoft.XMLDO M");
dom.async = false;
dom.loadXML(xml );
} catch (error) {
try {
var parser = new
DOMParser();
dom =
parser.parseFro mString(xml, "text/xml");
delete parser;
} catch (error2) {
if (debug)
alert("XML parsing is
not supported.");
}
}

return dom;

}

no matter what i do i keep getting that search has no properties. but
the below line is correct, isn't it?
var search = dom.getElements ByTagName('sear ch').item(0);

so, if that is correct, then the problem is the content of the
response. but, when i uncomment my errorhandling code:

//UNCOMMENT FOR ERROR CHECKING - RESPONSETEXT IN NEW WINDOW
//var doc = ajaxRequest.res ponseText;
// doc=doc.replace (/</g, '<').replace(/\>/g, '>');
//childWin=window .open("", "childwin") ;
//childWin.docume nt.write("<pre> "+doc+"</pre>");
//childWin.docume nt.close();

i get the below line:

<?xml version='1.0'
encoding='ISO-8859-1'?><search><se x>male</sex><agefrom>18 </agefrom><ageto> 100</ageto><type>som etype</type></search>
so, that is everything. i am probably overlooking something obvious
but, at this point, i need another set of eyes to point
it out.

thanks.
Oct 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1535
by: Michael Bourgon | last post by:
Here's something I found a few months ago, and it seems to come in handy pretty often, so I figured I'd share. Disclaimer: you are modifying a SYSTEM TABLE. This may not work in the next version of SQL Server. When you right click on a Database in the Enterprise Manager and choose Properties, in order to show the last backup time, it has to go through MSDB and find the last backup date for the database. Unless you're carefully...
3
2089
by: kj | last post by:
This problem is driving me nuts. The code at the end of this post below works fine with IE, but fails with Mozilla. You can see it in action at http://tinyurl.com/2jvo3 With Mozilla 1.4 and 1.6, the function msg works fine if it's installed as an onclick handler for the button, but fails as an onload handler for the page. The error is "console has no properties", and is triggered by the line.
134
7886
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that means that if I misspell a variable name, my program will mysteriously fail to work with no error message. If you don't declare variables, you can inadvertently re-use an variable used in an enclosing context when you don't intend to, or
2
1764
by: holysmokes99 | last post by:
I am developing a component in .Net 1.1, and want to debug it using the "start external program" of the debugger in the IDE. The program I want to start references both 1.1 and 2.0 components. The problem is that when I launch this from VS2003, the external program starts only for a moment and then bails out of memory with no error, and the ide returns to a stopped state awaiting my input. If I remove the 2.0 framework, at least the...
21
7854
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
2
2493
by: jj555s | last post by:
I get a Message that says "No error occured." when I tried to write in a file. What does it mean?
1
2672
by: luispunchy | last post by:
I have an accordion style dropdown list/sublist menu (functions similar to the "today on WebMD video" widget found on http://www.webmd.com/) - it will allow users to click on a headline (from the main list) to open up the full listing (sublist) below that headline. My JavaScript is almost but not quite working as needed. It also serves up an error that an object "has no properties". The particular error message and line of code it refers to:...
2
1852
bugboy
by: bugboy | last post by:
Hi i'm a beginner at php and my simple web query page doesn't work.. i swear i had it working at one point but now i've come back to it it doesn't. • My form works • My DB connection works • My query works in my client... so it should work here. It has the right DB and all the right table names... i've only changed the word = 'myword' to word = '$word' so it will use the form value instead. • My while loop doesn't return results.....
6
5702
by: Uh Clem | last post by:
Is there a way to update form/control properties via VBA and have them still be there after the form is re-opened? When a textbox value is updated by the user, I need that value to be there next time the form is loaded. Sure I could store the value in the database, but this happens to be an unbound form, so I'm hoping for something simple. The forum post Default Value set the same as last valus for field describes how how to set a...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8777
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9452
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9184
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6737
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6033
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4813
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.