witam. mam taki oto kod:
<?php
$myfile = fopen("plik.txt", "w") or die("dupa!");
$txt = "ppp\n";
fwrite($myfile, $txt);
fclose($myfile);
echo('<?xml version="1.0" encoding="UTF-8"?><query>ppp123456jjjjjj</query>');
?>
document.getElementById("findaddr").addEventListener("click", function(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST","php/ppp.php", true);
var xmlDoc;
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
xmlDoc = xmlhttp.responseXML;
console.log(xmlDoc);
// alert( xmlDoc.getElementsByTagName("query") );
}
};
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
var xml = "<?xml version='1.0'?><query>" + "zmienna" + "</query>";
xmlhttp.send(xml);
alert(xmlDoc.getElementsByTagName("query"));
});
Jak prawidłowo odebrać dane po stronie klienta (javascript) ?
zapytanie jest wysyłane prawidłowo(plik na sterwerze jest tworzony)
PS alertem staram się wyświetlić dane z serwera
w konsoli mam:
xmlDoc is undefined a przecież jest zdefiniowany