Mmmmm nonostante i tuoi consigli credo che cmq il codice sia "apposto"
a questo punto lo posto
codice:
// JavaScript Document
var myRequest = null;
var Dt;
function CreateXmlHttpReq2(handler) {
var xmlhttp = null;
try {
xmlhttp = new XMLHttpRequest();
} catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
xmlhttp.onreadystatechange = handler;
return xmlhttp;
}
function myHandler() {
if (myRequest.readyState == 4 && myRequest.status == 200) {
Dt = myRequest.responseText;
}
}
function esempio3() {
myRequest = CreateXmlHttpReq2(myHandler);
myRequest.open("GET","read_info.php");
myRequest.send(null);
}
alert(Dt);
Lancio la funzione esempio3() nel body con onload
Con questo codice mi da l'alert con scritto "undefined"
Se metto un altro alert(Dt) nella funzione myHandler()
aggiorno la pagina mi da in questo ordine:
1)Alert "undefined" //fuori dalle function
2)Alert con i dati //messo nella function