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
|
var xhr;
var POST="";
var idHtml="";
/*****************RECUPERATIONS DES VARIABLES*****************/
var montant2;
var mens2;
var duree2;
var age;
var ancien;
var banque;
var nbDebit;
var epargne;
var soldeF;
function getValues(){
montant2=document.getElementById('montant2').value;
mens2=document.getElementById('mens2').value;
duree2=document.getElementById('duree2').value;
age=document.getElementById('age').value;
ancien=document.getElementById('age').value;
banque=document.getElementById('banque').value;
nbDebit=document.getElementById('nbDebit').value;
epargne=document.getElementById('epargne').value;
soldeF=document.getElementById('soldeF').value;
}
try{
xhr = new XMLHttpRequest();
}catch(e){
var XmlHttpVersions = new Array('MSXML2.XMLHTTP.6.0',
'MSXML2.XMLHTTP.5.0',
'MSXML2.XMLHTTP.4.0',
'MSXML2.XMLHTTP.3.0',
'MSXML2.XMLHTTP',
'Microsoft.XMLHTTP');
for (i=0 ; i<XmlHttpVersions.length && !xhr ; i++){
try{
xhr = new ActiveXObject(XmlHttpVersions[i]);
}catch(e){
}
}
if(!xhr) alert("Votre ordinateur n'est pas compatible avec Ajax");
}
function showContent(page,id){
idHtml=id;
document.getElementById(idHtml).innerHTML = '<img src="img/loader.gif" alt="Chargement..." />';
switch(page){
/*************** ACCUEIL - INFORMATIONS ***********************/
case "pRef" : xhr.open("POST", "pRef.php", true);
getValues();
POST='montant2='+montant2+'&duree2='+duree2+'&mens2='+mens2+'&age='+age+'&ancien='+ancien;
POST+='&banque='+banque+'&nbDebit='+nbDebit+'&epargne='+epargne+'&soldeF='+soldeF;
alert(POST);
xhr.send(POST);
xhr.onreadystatechange = insertContent;
break;
/****************** EN COURS ****************************/
default : xhr.open("GET", "introuvable.php", true);
xhr.send(null);
xhr.onreadystatechange = insertContent;
}
}
/*******************************************************************************************
Insertion du contenu HTML dans le div adapté
*******************************************************************************************/
function insertContent(){
if(xhr.readyState == 4 && xhr.status == 200){
if (xhr.responseText != ""){
document.getElementById(idHtml).innerHTML = xhr.responseText ;
}
}
} |
Partager