brothers!! :) I am e beginner in ajax and I have a problem retrieving a note value from an response XML. what i am trying to do is (simple i think): with ajax I make a request for an XML file to a PHP page. I get the XML but i can not gat the notes values.
my simple XML:
<items>
<item>
<name>..</name>
<address>..</address>
<owner>..</owner>
</item>
</items>
my PHP (that response):
<?php
header('Content-Type: text/xml');
$doc = new DOMDocument();
$doc->formatOutput=true;
$doc->load('data.xml');
echo $doc->saveXML();
?>
my request function:
function getUserParameters(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function Return(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
var result = xmlhttp.responseXML;
var name= result.getElementsByTagName("name");
var val = name[0].childNodes[0].nodeValue;
alert(val);
}
}
xmlhttp.open("GET","request.php",true);
xmlhttp.send();
}
everything works ok, but when i try to alert(val) the string is null. Nothing appear! can anyone tell me what i do wrong please?
theks a lot for your time.