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 80 81 82 83 84 85 86 87 88 89
   |  
 
var affichage=0;
var passage;
 
function createRequestObject()
{
   var http = null; // Notre objet XMLHttpRequest
 
   if (window.XMLHttpRequest) 
   {
       http = new XMLHttpRequest();
   }
   else if (window.ActiveXObject)  // if IE
   { 
	var ieversions = ['Msxml2.XMLHTTP',
				'Microsoft.XMLHTTP',
				'Msxml2.XMLHTTP.5.0',
				'Msxml2.XMLHTTP.4.0',
				'Msxml2.XMLHTTP.3.0'
			       ]; 
 
	for(var i=0; !http && i<ieversions.length; i++) 
	{ 
	     try
	     {
		http = new ActiveXObject(ieversions[i]);
	     } 
	     catch(e)  
             {  
                 http = null;
             }
	}
   }
 
   if (!http) 
      alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
 
   return http;
}
 
 
function gestionClic1()
{
    var info = document.getElementById('info');
 
    if(affichage==0)
    {
 
       if(passage!=1)
       {
         var miseajourDIV = document.createElement( 'div' );	
         miseajourDIV.setAttribute("id", "info");
         miseajourDIV.setAttribute("width", "60%");
         miseajourDIV.setAttribute("align", "center");
         document.getElementById('test2').appendChild(miseajourDIV);
	 passage=1;
       }
 
       info.style.visibility="visible";
       http = createRequestObject();
 
       if(http)
       {
           http.open('GET', './scripts/informations-ajax.php', true);
           http.onreadystatechange = function()
           {
               if(http.readyState == 4)
               {
                   if(http.status == 200 || http.status == 304)
                        info.innerHTML = http.responseText;
                           else
                              info.innerHTML = "<strong>Error " + http.status + " : " + http.statusText + "... .. .</strong>";
               }
               else info.innerHTML = '<em>Chargement... veuillez patienter... .. .</em>';
           };
           http.send(null);
        }
        else info.innerHTML = '<em>Echec du chargement des données... .. .</em>';
 
        affichage=1;
    }
    else
    {
       info.innerHTML = "";
       info.style.visibility = "hidden";
       affichage=0;
    }
} | 
Partager