/* Define o tempo */ var waittime=500; /* Variaveis internas*/ document.getElementById("chatwindow").innerHTML = ""; var xmlhttp = false; var xmlhttp2 = false; /*LENDO*/ function ajax_read(url) { if(window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); if(xmlhttp.overrideMimeType){ xmlhttp.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ } } } if(!xmlhttp) { alert('Prosseguindo :( Não foi possível criar a instancia XMLHTTP '); return false; } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4) { if(xmlhttp.status==200){ document.getElementById("chatwindow").innerHTML =unescape(xmlhttp.responseText); clearTimeout(intUpdate); zeit = new Date(); ms = (zeit.getHours() * 24 * 60 * 1000) + (zeit.getMinutes() * 60 * 1000) + (zeit.getSeconds() * 1000) + zeit.getMilliseconds(); intUpdate = setTimeout("ajax_read('retorna_on_off.php?x=" + ms + "')", waittime); } intUpdate = setTimeout("ajax_read('retorna_on_off.php?x=" + ms + "')", waittime); } } xmlhttp.open('GET',url,true); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xmlhttp.send(null); } /* Começa ;) */ var intUpdate = setTimeout("ajax_read('retorna_on_off.php')", waittime);