Created
December 26, 2014 19:15
-
-
Save devdays/58b230055e6e0bc7be4b to your computer and use it in GitHub Desktop.
Single Page App - Checking connection using XMLHttpRequest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function check() { | |
var z, xml = null; | |
xml = new XMLHttpRequest(); | |
// use xmlHttp object shown in the next snippet if you need to support IE6 | |
// xml = new xmlHttp | |
xml.open("get", url, false); | |
try { | |
xml.send(null); | |
} catch(z) { | |
alert("Network failure"); | |
return; | |
} | |
if ((xml.status >= 200 && xml.status <= 300) || xml.status == 304) { | |
var hi = xml.responseText; | |
} else { | |
alert("No Internet Connection! You will have to enter information by hand"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment