Javascript: Check if server is online?
<p>What's the fastest way to check if my server is online via javascript?</p>

<p>I'm trying the following AJAX..</p>

<pre><code>    function isonline(){
    var uri = 'MYURL'
    var xhr = new XMLHttpRequest();
    xhr.open("GET",uri,false);
    xhr.send(null);
    if(xhr.status == 200)
    {
        //is online
        return xhr.responseText;
    }
    else
    {
        //is offline
        return null;
    }   
}
</code></pre>

<p>The problem is it never returns if it's offline.. how would I set a timeout so that if it doesn't return after a certain amount of time I assume offline?</p>
