1.11M Members

XMLHttpRequest set timeout

 
0
 

Hello. I have a function that checks the internet connection. I need to set a timeout to it. I have tried without success to do that. Please help. Here is the function:

function isOnline() {
    if(navigator.onLine){
        var uri = baseUrl+'ping';
        var xhr = new XMLHttpRequest();
        xhr.open('GET',uri,false);
        try{
            xhr.send();
            return true;
        }catch(err){
            return false;
        }
    }else{
        return false;
    }


}
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: