<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
var Request = false;
var docElement, childOne, childTwo, textNode, targetData;
Request = new XMLHttpRequest();
else if (window.ActiveXObject)
Request = new ActiveXObject("Microsoft.XMLHTTP");
Request.onreadystatechange = function()
if (Request.readyState == 4 && Request.status == 200)
var xmlDoc = Request.responseXML;
docElement = xmlDoc.documentElement;
childOne = docElement.firstChild;
childTwo = childOne.nextSibling;
textNode = childTwo.firstChild;
targetData = textNode.nodeValue;
window.alert("There are " + targetData + " in the library.");
var i = 0;
for (i = 0; i < xmlFile.childNodes.length; i++)
var tag = xmlFile.chlidNodes[i];
if (tag.nodeType == 1)
if ((tag.nodeType == 3) && (/^\s+$/.test(tag.nodeValue)))
XML - library.xml
<?xml version="1.0" encoding="UTF-8"?>
I'd have to look this up myself, however, it is a better idea to use JSON instead of XML for AJAX.
I just realized how funny that sounds considering what AJAX stands for, however, look at using JSON.
ok thanks, i'll look into JSON! but if any of you have an idea why this is not working, please tell, thank you :)
How are you serving the documents?
all documents are in the same folder. The problem is I don't know the problem. Would you know what's wrong with my code? I can't seem to read any kind of XML. Thanks
OK, but how are you serving the documents; Apache, IIS, Windows localHost?
Airshow's tag line says it all
50% of the solution lies in accurately describing the problem!
I would also say it could be modified to say the following:
40% of the solution lies in accurately describing the problem!
40% of the solution lies in understanding the problem!
20% of the solution lies in good coffee!
I just read out the code, but didn't find any problems with it.
I'm pretty sure your ajax call is not being served at all.
You may have ran into some sort of a security issue.