function NumeroCasuale(Da,A) { return Math.floor((A-Da+1) * Math.random() +Da); } var CaricaPagina_DatiPagina = '' var req var semaforo=true var imgProgress = new Image(); imgProgress.src = '/img/progressbar.gif'; function CaricaPagina(url, target, method, parameters, strFunzione) { if(semaforo){ semaforo=false url+=(url.indexOf('?')>0)?'&':'?'; url+='nocache='+NumeroCasuale(0,9999); //alert(url); //out.innerHTML+=('carico pagina: '+url+'
\n'); if(method == undefined || method == '')method="get" if(imgProgress!=''){ if(typeof(target)!='string'){ for(var i=0;i'; } else{ if(target!=''){ //document.getElementById(target).innerHTML = 'caricamento dati in corso...'; document.getElementById(target).innerHTML = ''; } } } if(window.XMLHttpRequest){ req = new XMLHttpRequest(); }else if(window.ActiveXObject){ req = new ActiveXObject("Microsoft.XMLHTTP"); } if(req){ req.onreadystatechange = function() { CaricaPaginaDone(url, target, method, strFunzione); }; req.open(method, url, true); if ( (method == "POST") || (method == "post") ){ //alert('post: '+url) req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.send(parameters); } else req.send(""); } } } function CaricaPaginaDone(url, target, method, strFunzione) { var stringa //out.innerHTML+='readyState: '+req.readyState+'
' if (req.readyState == 4) { semaforo=true if(typeof(target)!='string'){ for(var i=0;i stata caricata la pagina: '+url+'
\n') } } } else{ //out.innerHTML+=target+'
'; if (document.getElementById(target)){ if (req.status == 200) { stringa = req.responseText+''; //alert(stringa) document.getElementById(target).innerHTML = stringa; var re=/<\!--\$dati:([^(-->)]*)-->/gi re=/<\!--\$dati:(.*)\$dati-->/ var ris = req.responseText.match(re); if(ris && ris[1])CaricaPagina_DatiPagina=ris[1] else CaricaPagina_DatiPagina='' //alert(CaricaPagina_DatiPagina) if(strFunzione){ //alert(strFunzione) setTimeout(strFunzione,1); } }else{ document.getElementById(target).innerHTML="Error:\n"+req.statusText+"\n"+req.responseText; CaricaPagina_DatiPagina=''; } // out.innerHTML+=(' stata caricata la pagina: '+url+'
\n') } } } } function CaricaPaginaDoneConDati(url, target, method) { if (req.readyState == 4) { if (req.status == 200) { document.getElementById(target).innerHTML = req.responseText; var re=/<\!--\$dati:([^(-->)]*)-->/gi re=/<\!--\$dati:(.*)\$dati-->/ var ris = req.responseText.match(re); if(ris[1])CaricaPagina_DatiPagina=ris[1] else CaricaPagina_DatiPagina='' AnalizzaDatiPagina(); }else{ CaricaPagina_DatiPagina='' document.getElementById(target).innerHTML="Error:\n"+req.statusText+"\n"+req.responseText; } } } function CaricaPaginaConDati(url, target, method, parameters) { if (method == undefined)method="get" //document.getElementById(target).innerHTML = 'caricamento dati in corso...'; if(imgProgress!='') document.getElementById(target).innerHTML = ''; if(window.XMLHttpRequest){ req = new XMLHttpRequest(); }else if(window.ActiveXObject){ req = new ActiveXObject("Microsoft.XMLHTTP"); } if(req){ req.onreadystatechange = function() { CaricaPaginaDoneConDati(url, target, method); }; req.open(method, url, true); if ( (method == "POST") || (method == "post") ){ req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.send(parameters); } else req.send(""); } }