Ciao a tutti
Sto cercando di fare una semplice request dopo aver caricato la pagina. Questa è la mia funzione che viene richiamata dal onload del body:
codice:
function showUser(){
xmlHttp = getXmlHttpObject()
/*if(xmlHttp == null){
alert("Your browser do not support HTTP Request");
return;
}*/
var url="request.php";
alert(url);
/*xmlHttp.onreadystatechange = stateChanged;
xmlHttp.open("POST", url, true);
xmlHttp.send(null);*/
}
I commenti che vedete in pratica li ho messi per capire dov'è che si ferma, cioè dov'è che mi comincia a dare errore nella visualizzazione. Ed in pratica ho visto che l'errore sta proprio nella prima stringa, cioè non va il GetXmlHttpObject, con o senza ; . Infatti se commento quella stringa mi fa quell'alert. E questa è la funzione getXmlHttpObject
codice:
function getXmlHttpObject(){
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
return xmlHttp;
}
}
Come posso risolvere?
Grazie a tutti