function ajax() {
if(navigator.onLine){
const myTimeOut= setTimeout(driver,5000);
function driver() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if(this.readyState==4 && this.status == 200){
document.getElementById('msg').innerHTML=this.responseText;
}
};
xmlhttp.open("GET", "ajax.php", true);
xmlhttp.send();
myStopFunction();
}
} else {
// avisar para tivar a internet
}
}
function myStopFunction() {
clearTimeout(myTimeout);
}
Sem comentários:
Enviar um comentário