Io uso questo che va benissimo:
codice:
function objAjx(){
var xmlhttp = null;
if(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera, Internet Explorer 7
}
else if(window.ActiveXObject)
{
try
{
xmlhttp = new ActiveXObject("MSXML2.XMLHTTP"); // Internet Explorer 6
}
catch(e)
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer 4,5
}
}
else
{
xmlhttp = null;
}
return xmlhttp;
};
function Visualizza(div){
AjaX = objAjx();
if(AjaX){
//Chiamo la funzione caricoRisultati quando c'è un cambio evento
AjaX.onreadystatechange=function(){
mostroRisultati(AjaX,div)
}
//Invio i dati alla pagina .asp
AjaX.open('GET', "studi.asp", true)
AjaX.send(null)
}
}
function mostroRisultati(AjaX,div){
//Se è andato tutto bene faccio vedere il risultato
if (AjaX.readyState == 4 && (AjaX.status==200 || window.location.href.indexOf("http")==-1)){
document.getElementById(div).innerHTML = AjaX.responseText
}
}