buongiorno a tutti sono in paranoia completa!
ho preso un esempio standard di chiamata ajax
e stavo cercando di migliorarlo aggiungendo la possibilità di definire il
div nel quale deve finire il risultato. ho deciso di chiamare la variabile elementoid
ma non funziona ...mi pare che il problema stia nella riga
XMLHTTP = RicavaBrowser(CambioStato(elementoid));
suggerimenti?
varXMLHTTP;
function Richiesta(Stringa,elementoid)
{
if (Stringa.length > 0)
{
var url = "ajax.asp?nome=" + Stringa.toUpperCase();
XMLHTTP = RicavaBrowser(CambioStato(elementoid));
XMLHTTP.open("GET", url, true);
XMLHTTP.send(null);
}
else
{
document.getElementById(a).innerHTML = "";
}
}
function CambioStato(elementoid)
{
if (XMLHTTP.readyState == 4)
{
var R = document.getElementById(elementoid);
R.innerHTML = XMLHTTP.responseText;
}
}
function RicavaBrowser(QualeBrowser)
{
if (navigator.userAgent.indexOf("MSIE") != (-1))
{
var Classe = "Msxml2.XMLHTTP";
if (navigator.appVersion.indexOf("MSIE 5.5") != (-1));
{
Classe = "Microsoft.XMLHTTP";
}
try
{
OggettoXMLHTTP = new ActiveXObject(Classe);
OggettoXMLHTTP.onreadystatechange = QualeBrowser;
return OggettoXMLHTTP;
}
catch(e)
{
alert("Errore: l'ActiveX non verrà eseguito!");
}
}
else if (navigator.userAgent.indexOf("Mozilla") != (-1))
{
OggettoXMLHTTP = new XMLHttpRequest();
OggettoXMLHTTP.onload = QualeBrowser;
OggettoXMLHTTP.onerror = QualeBrowser;
return OggettoXMLHTTP;
}
else
{
alert("L'esempio non funziona con altri browser!");
}
}