var xhr = null; // Fonction de creation de l'objet XMLHttpRequest qui resservira pour chaques fonctions AJAX function getXhr() { if(window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else if(window.ActiveXObject) { try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } } else { alert("Su navegador no soporta los objetos XMLHTTPRequest, pongalo al dia."); xhr = false; } } function makeRequest() { getXhr(); xhr.onreadystatechange = function() { if(xhr.readyState == 4 && xhr.status == 200) { if (xhr.responseText != 0) { //alert(eval(xhr.responseText)); //alert("hello"); //alert(xhr.responseText); document.getElementById('message_alert').innerHTML = xhr.responseText; //longueurCible = document.getElementById("dropin").firstChild.length; //document.getElementById("dropin").firstChild.replaceData(0, longueurCible, xhr.responseText); initbox(); } } } var url = '/account/mailbox/windowAlert.php'; xhr.open('POST', url ,true); xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); xhr.send("type="+url); } setInterval(makeRequest, 60000); // on effectue une nouvelle requĂȘte serveur toutes les 60 secondes (60000)