View Single Post
Old 11-22-2007, 03:40 PM   PM User | #1
binaryWeapon
Regular Coder

 
Join Date: Sep 2007
Location: AZ, USA
Posts: 685
Thanks: 6
Thanked 46 Times in 46 Posts
binaryWeapon is on a distinguished road
Thumbs up [resolved] Desperate AJAX question

Edit: I didn't figure out what was wrong with my code, but I found a different script that works. Still, if anyone can tell me my error here, it would be appreciated!


AUUUUUGH! I've been working on this simple script FOREVER and I finally got it work but then something happened on my computer and I lost it and now I have to start over. And now I'm lost on the simplest part of it!

external JS:
Code:
var xmlDoc; //pass a variable to be used later
if (window.ActiveXObject) // Code for IE:
{
	xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.async=false;
	xmlDoc.load("forum.xml"); // Path to the forum
}

else if (document.implementation && document.implementation.createDocument) // code for Mozilla, Firefox, 

Opera, etc.
{
	xmlDoc=document.implementation.createDocument("","",null);
	xmlDoc.load("forum.xml"); // Path to the forum
}
else
{
	alert('Browser error!\nYour browser is too old for this forum to parse the database.\nTo fix this 

problem, upgrade to a new browser.'); //Message if browser doesnt support AJAX
}
alert(xmlDoc.getElementsByTagName("excalo")[0].getAttribute("users"));
HTML:

Code:
<html>
<head>
<script src="func.js">
</script>
</head>
<body>
<form name="register">
Username: <input type="text" value="admin" name="username"><br>
Password: <input type="password" value="admin" name="password"><br>
Password Verification: <input type="password" value="admin" name="passwordVerification"><br>
</form>
</body>
</html>
XML file forum.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<excalo users="hello there">
<tester>Yo</tester>
</excalo>
I'm just trying to get an alert with the value of the users attribute. I've rewritten this code sooo much trying to get it to work, I think my mind is numb and is probably a simply solution but I just can't figure it out!

The error I'm getting in firefox is:
Quote:
xmlDoc.getElementsByTagName("excalo")[0] has no properties
The same thing happens when I try to get an alert of the "tester" element.
Edit: Except, it says
Quote:
xmlDoc.getElementsByTagName("tester")[0] has no properties
UUUGH!

Last edited by binaryWeapon; 11-22-2007 at 05:43 PM.. Reason: Problem Resolved
binaryWeapon is offline   Reply With Quote