Salve a tutti, il titolo dice quasi tutto, dovrei recuperare da un file script.php tre variabili chiamate, $id_bacheca, $mex_utente, $avatar, e faccio in questo modo:
codice:
function Update()
{
return Request();
}
window.setTimeout("Update()", 900)
var XMLHTTP;
function Request()
{
XMLHTTP = GetBrowser(ChangeStatus);
XMLHTTP.open("GET", "script.php", true);
XMLHTTP.send(null);
window.setTimeout("Request()", 500)
}
function ChangeStatus()
{
if (XMLHTTP.readyState == 4)
{
var R = document.getElementById("contenitore");
var response = XMLHTTP.responseText;
response = XMLHTTP.responseXML.documentElement;
//errore che mi esce quando esegue lo script: ( uncaught TypeError: Cannot read property'documentElement' of null)
idArray = response.getElementsByTagName("id_bacheca");
messageArray = response.getElementsByTagName("mex_utente");
avatarArray = response.getElementsByTagName("avatar");
for(var i=0; i<idArray.length; i++){
var id = idArray.item(i).firstChild.data.toString();
var message = messageArray.item(i).firstChild.data.toString();
var avatar = avatarArray.item(i).firstChild.data.toString();
var htmlMessage="";
htmlMessage +="<div id=\"contenuto_messaggio\">";
htmlMessage +="<div id=\"avatar_messages\">[img]+ avatar + [/img]</div>";
htmlMessage +="<div class=\"contenuto_bac\"><div id=\"elimina_messaggio\"><input type=\"button\" onclick=\"delete_message("+id+")\" id=\"pulsante_elimina\" value=\"x\"/></div>";
htmlMessage +="<div class=\"contenuto_contenuto\">"+message+"</div>";
htmlMessage +="<div id=\"pulsante_commenti\"><input type=\"button\" id=\"pulsante_comment\" value=\"Commenti\" /></div></div>";
R.innerHTML=htmlMessage;
}
}
}
function GetBrowser(FindBrowser)
{
if (navigator.userAgent.indexOf("MSIE") != (-1))
{
var Class = "Msxml2.XMLHTTP";
if (navigator.appVersion.indexOf("MSIE 5.5") != (-1));
{
Class = "Microsoft.XMLHTTP";
}
try
{
ObjXMLHTTP = new ActiveXObject(Class);
ObjXMLHTTP.onreadystatechange = FindBrowser;
return ObjXMLHTTP;
}
catch(e)
{
alert("attenzione: l'ActiveX non sarà eseguito!");
}
}
else if (navigator.userAgent.indexOf("Mozilla") != (-1))
{
ObjXMLHTTP = new XMLHttpRequest();
ObjXMLHTTP.onload = FindBrowser;
ObjXMLHTTP.onerror = FindBrowser;
return ObjXMLHTTP;
}
else
{
alert("Il browser che stai utilizzando non supporta questa funzionalita");
}
}
Qualcuno può aiutarmi a risolvere questo problema, ringrazio anticipatamente per la risposta