 |
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Fri Sep 09, 2005 7:41 pm Post maybe stupid Post subject: AJAX (JavaScript Question) |
 |
|
|
|
I've been working off the following URL:
http://www.phpbuilder.com/columns/kassemi20050606.php3
Although, this tutorial is pretty much hacked up, several key things are missing from it. But in particular, I did get the majority of the idea behind the tutorial down and working. The only issue is right now I'm trying to parse XML data with Javascript, and that, isn't working right.
function processReqChange() {
// only if req shows "loaded"
if (http.readyState == 4) {
if (http.status == 200) {
document.submitLink.categories.disabled = false;
alert("We're good to go...");
var XMLResponse = http.responseXML;
var product_list = XMLResponse.getElementsByTagName("list");
var product_id = XMLResponse.getElementsByTagName("category");
alert("SIZE: " + product_list.length + "x" + product_id.length); // returns: SIZE: 1 x 3
var select = document.submitLink.categories;
//clearTopicList(select);
for (var i = 0; i < product_id.length; i++) {
alert("i = " + i + " " + product_id[i].getAttribute('id') + " " + product_id[i].getAttributeNode('name'));
}
alert('DONE.');
} else {
alert("There was a problem retrieving the XML data:\n" +
http.statusText);
}
}
} |
In the tutorial on the website has the following line:
var product_list = XMLResponse.getElementByTagName("list");
When Firefox says 'getElementByTagName' is not a function. So I made it getElementsByTagName - it appears to work, sort of. The code:
product_id[i].getAttribute('id')
works as well;
Essentially, I need to know how I can grab the 'name' tags in the XMl sheet from below (the ID attribute is read OK)...
<list>
<category id="1">
<name>History</name>
</category>
<category id="2">
<name>Art</name>
</category>
<category id="3">
<name>CSC</name>
</category>
</list> |
Perhaps this isn't valid XML so it's not being parsed correctly?
Any ideas, comments, suggestions? Please keep the ability to go off-track down to a minimum. Laterly, there's more than enough junk being posted then what's needed. _________________ Performance is often the art of cheating carefully. - James Gosling
Last edited by CypherJF on Sat Sep 10, 2005 9:03 am, edited 1 time in total |
|
Back to top |
|
 |
Maverick

Age:41 Gender: Joined: Feb 26 2005 Posts: 1521 Location: The Netherlands Offline
|
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Sat Sep 10, 2005 9:02 am Post maybe stupid Post subject: |
 |
|
|
|
That above didn't work right but when I do do this:
product_id[i].childNodes.item(0) - it returns [object Text].
So I tried
product_id[i].childNodes.item(0).data - which returned a new line from what it appears but no data.
Yeah that ';' wasn't supposed to be there (it doesn't actually exist in the XML). |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 33 page(s) served in previous 5 minutes.
|