use javascript to test if server is reachable
<p>I have a javascript application that loads data asynchronously from a server within my company's firewall.  We sometimes need to show this application outside of the firewall but it is not always possible to get on the VPN.  For this reason, we configured the firewall to allow public requests for this data on a specific port.  The catch: when I am inside the corporate network, I can only load data using the server's DNS name due to a peculiar configuration of the firewall.  Outside of the corp network, I have to use the server's public IP address..</p>

<p>Currently we distribute two versions of the javascript application -- one which works within the firewall and one that works outside of it.  We would like to distribute one app -- one that tests the URLs and then, depending on which is reachable, continue to use that address to load data.  </p>

<p>I have been using jQuery's <code>$.ajax()</code> call to load the data and I noticed there is a <code>timeout</code> parameter.  I thought I could use a short timeout to determine which server is unreachable..  However, this "countdown" doesn't seem to start until the initial connection to the server is made.</p>

<p>Any thoughts on how to determine, in javascript, which of two servers is reachable?</p>
