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;
    }


}
2
Contributors
1
Reply
8
Views
3 Years
Discussion Span
Last Post by stbuchok
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.