Ciao a tutti, spero che sia capitato a qualcun altro il mio stesso problema.
Il codice che vedete di seguito utiilzza la funzione ahah, credo già conosciuta da molto di voi.
Il problema è il seguente: la richiesta xmlHttpRequest() funziona con qualsiasi browser lato server (on line) mentre lato client (locale, off line) funziona con tutti i browser tranne che con Internet Explorer 7 e a me serve che funzioni lato client.
Il codice è:
-----------------------------------------------------------------------------------------
var req;
var ajaxable;
var ajaxname = "ajaxable";
function getAjaxable(){
ajaxable = document.getElementById(ajaxname);
}
function ahah(url) {
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req) {
req.onreadystatechange = function() {
ahahDone();
};
req.open('GET', url, true);
req.send("");
}
}
function ahahDone(){
if(req.readyState == 4){
if(req.status == 200 || req.status == 0)
buildPagina();
else
ajaxable.innerHTML="ahah error";
}
}
function buildPagina(){
ajaxable.innerHTML = analizzaTesto(req.responseText);
initLightbox();
}
function analizzaTesto(testo){
var regexp = new RegExp("([\\w\\W]*)");
regpag = regexp.exec(testo);
if(regpag==null)
return "";
else
return regpag[1];
}
-----------------------------------------------------------------------------------------