1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
...
function verifcodeq(codeq){
if(typeof(codeq)!='undefined' && codeq!=null && codeq != '') {
var codeqLen = codeq.length;
console.log('codeqLen : ' + codeqLen);
if(codeqLen < 5){
writedivcodeq('<img border="0" src="../imgs/form_warning.png" width="20" height="20" alt="PAS OK" title="PAS OK">');
checkResponse3 = false;
} else {
file('./run.exe/?vr=CODEQ',escape(codeq),function(response3){
console.log("response3" , response3);
if(response3 == 1){
writedivcodeq('<img border="0" src="../imgs/form_ok.png" width="20" height="20" alt="OK" title="OK">');
checkResponse3 = true;
} else if(response3 == 2){
writedivcodeq('<img border="0" src="../imgs/form_warning.png" width="20" height="20" alt="PAS OK" title="PAS OK">');
checkResponse3 = false;
} else {
console.log("Valeur inconnue !");
writedivcodeq('');
}
checkCheck(); //on vérifie l'état des réponses
});
}
checkCheck(); //on vérifie l'état des réponses
} else {
writedivcodeq('');
}
}
function file(url,codeq, callBack) {
var data ='codeq='+escape(codeq);
var result = postAjax(url,data,callBack);
return result;
}
/**
* Retourne l'objet xhr
*/
function getXhr(){
var xhr = null;
try{
if( typeof ActiveXObject == 'function' ){
xhr = new ActiveXObject("Microsoft.XMLHTTP");
} else {
if( window.XMLHttpRequest ){
xhr = new XMLHttpRequest();
}
}
} catch(e) {
alert(e.message);
return null;
}
return xhr;
}
/**
* Ajax : POST
*/
function postAjax(url,data,callBack){
var xhr = getXhr();
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
xhr.onreadystatechange = function() {
if(this.readyState == 4){
console.log('status', xhr.status);
console.log('DONE', xhr);
if(xhr.status == 200){
console.log('responseText',xhr.responseText);
callBack(xhr.responseText);
}else{
//error
alert('Erreur !' + xhr.status + " -> " + xhr.responseText);
}
}
};
xhr.send(data);
} |
Partager