/* ////////////////////////////////////////////////////////// // // // COPYRIGHT 2007 MENTASOLUTIONS ALL RIGHTS RESERVED // // utilisation de ce script sans autorisation interdite // // // ////////////////////////////////////////////////////////// Valeur possible de la propriété readyState 0 = non initialisé ; 1 = ouverture. La méthode open() a été appelée avec succès ; 2 = envoyé. La méthode send() a été appelée avec succès ; 3 = en train de recevoir. Des données sont en train d'être transférées, mais le transfert n'est pas terminé ; 4 = terminé. Les données sont chargées. */ //XHRStates=new Array("Non initialisé","0uverture ok","Envoyé ok","En train de recevoir.","Terminé. Données chargées."); XHRStates=new Array("StandBy;","Connecté, patientez svp ...","Envoyé","Réception","Terminé."); XHRISCONNECTING=false; alertPBConnexion="La derniere operation ne s'est pas deroulee correctement.\r\nProblème de connexion probable. Aucune modification ne peut être enregistée.\t\nVeuillez recharger la page."; function AjaxBox(cxMethod,urlString,pId_container,parameters,callBackFunction){ var cxMethod=cxMethod;// GET ou POST var urlString=urlString;// url qui sera appelée var parameters=parameters;//parametres en cas de post var id_container=pId_container;//id de l'element dans lequel afficher le résultat var xhr;//objet XMLHttpRequest var callBackFunction=callBackFunction;//fonction a appeler en cas de succes (succes=ok) var xmlMode=false; this.XHRGET=XHRGet; this.XHRPOST=XHRPost; this.XHRSATECHANGE=XHRStateChange; this.XHRGETXML=XHRGetXML; this.XHRPOSTANDGETXML=XHRPostAndGetXML; XHRISCONNECTING=false; //construtor if (window.XMLHttpRequest)// Objet de la fenêtre courant { xhr = new XMLHttpRequest();// Firefox, Safari, ... } else if (window.ActiveXObject)// Version ActiveX { xhr = new ActiveXObject("Microsoft.XMLHTTP");// Internet Explorer } document.getElementById("wait").style.visibility="visible"; // // function XHRGet(){ if(XHRISCONNECTING==false){ xhr.abort(); XHRISCONNECTING=true; xhr.open('GET',urlString, true); xhr.onreadystatechange=this.XHRSATECHANGE; xhr.send(null); }else{ alert(alertPBConnexion); } } // // function XHRGetXML(){ if(XHRISCONNECTING==false){ xhr.abort(); XHRISCONNECTING=true; xmlMode=true; xhr.open('GET',urlString, true); xhr.onreadystatechange=this.XHRSATECHANGE; xhr.send(null); }else{ alert(alertPBConnexion); } } // // function XHRPostAndGetXML(){ if(XHRISCONNECTING==false){ xhr.abort(); XHRISCONNECTING=true; xmlMode=true; xhr.open('POST',urlString, true); xhr.onreadystatechange=this.XHRSATECHANGE; xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.send(parameters); }else{ alert(alertPBConnexion); } } // // function XHRPost(){ if(XHRISCONNECTING==false){ document.getElementById("ajaxState").innerHTML="Initialisation..."; XHRISCONNECTING=true; xhr.abort(); xhr.open('POST',urlString, true); xhr.onreadystatechange=this.XHRSATECHANGE; xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.send(parameters); }else{ alert(alertPBConnexion); } } function XHRStateChange(){ info=XHRStates[xhr.readyState]; if(xhr.readyState<4){ info=info; } if(document.getElementById("ajaxState")!=null){ document.getElementById("ajaxState").innerHTML=info; }else { alert(info); } if (xhr.readyState == 4) { if(xmlMode==false){ newtext=xhr.responseText; if(id_container!=''){ document.getElementById(id_container).innerHTML=newtext; if(document.getElementById("erreur")!=null && typeof(document.getElementById("erreur"))!=undefined)alert(document.getElementById("erreur").innerHTML); } }else{ xmlDoc=xhr.responseXML; try{ document.asyncXMLDoc=xmlDoc; document.getElementById(id_container).innerHTML=xmlDoc; } catch(ex){} } // if(callBackFunction!=undefined && xhr.status==200){ XHRISCONNECTING=false; if(typeof(callBackFunction)=="function"){callBackFunction();} else{eval(callBackFunction)} }; document.getElementById("wait").style.visibility="hidden"; if(xhr.status!=200){ newtext=xhr.responseText; alert("ERREUR!"); document.getElementById(id_container).innerHTML=newtext; } } } } ////////////////////////////////////////////////// function form2ValuesString(thisForm){ var valuesString=""; var curvalue=""; for(i=0;i