Intanto chiedo scusa per la genericità del titolo, ma davvero non saprei che altro scrivere , perchè il problema è molto strano, vengo al dunque
utilizzo AJAX per aggiornare solo un div in particolare uso questo codice:
codice:
function Login(){
var username = window.document.LogForm.uname.value;
var password = window.document.LogForm.passw.value;
var url = "login.php";
var parametri="username=" + username + "&password=" + password;
var success=false;
var XMLHTTPREQUEST_MS_PROGIDS = new Array(
"Msxml2.XMLHTTP.12.0",
"Msxml2.XMLHTTP.11.0",
"Msxml2.XMLHTTP.10.0",
"Msxml2.XMLHTTP.9.0",
"Msxml2.XMLHTTP.8.0",
"Msxml2.XMLHTTP.7.0",
"Msxml2.XMLHTTP.6.0",
"Msxml2.XMLHTTP.5.0",
"Msxml2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0",
"MSXML2.XMLHTTP",
"Microsoft.XMLHTTP"
);
var xmlHttp=null;
if (window.XMLHttpRequest != null)
{
//FF Opera Safari
xmlHttp = new window.XMLHttpRequest();
success=true;
}
else if (window.ActiveXObject != null)
{
// IE
for (var i = 0;
i < XMLHTTPREQUEST_MS_PROGIDS.length && !success;
i++)
{
try
{
xmlHttp = new ActiveXObject(XMLHTTPREQUEST_MS_PROGIDS[i]);
success = true;
}
catch (ex)
{}
}
}
if(!success)
{
alert("Il tuo browser non supporta AJAX");
}
xmlHttp.open("POST", url, true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", parametri.length);
xmlHttp.setRequestHeader("Connection", "close");// Riga incriminata
xmlHttp.send(parametri);
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
alert(xmlHttp.readyState);
if(xmlHttp.status==200){
document.getElementById("barra").innerHTML=xmlHttp.responseText;
Resize();
}
}
}
}
Quello che accade è che mentre con FireFox, Opera, Safari,Chrome, SeaMonkey e Flock tutto funziona bene con IE8 per far funzionare lo script devo cliccare più volte sul pulsante che lo lancia (anche 5 volte o più) altrimenti entro nello script ma non si verifica mai l'evento onreadystatechange, la soluzione che ho trovato per puro caso è quella di mette a commento la riga che ho evidenziato
xmlHttp.setRequestHeader("Connection", "close");
che stando a quello che ho letto serve la compatibilità con le vecchie versioni di FireFox qualcuno ne sa di più?