Skip to content

Instantly share code, notes, and snippets.

@synic
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save synic/e4759ed09142485b650f to your computer and use it in GitHub Desktop.
Save synic/e4759ed09142485b650f to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="2">
<title>Home Automation</title>
<script type='text/javascript'>
function GetSwitchAnalogData() {
nocache = "&nocache=" + Math.random() * 1000000;
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (this.readyState == 4) {
if (this.status == 200) {
if (this.responseText != null) {
document.getElementById("sw_an_data").innerHTML = this.responseText;
}
}
}
};
request.open("GET", "ajax_switch" + nocache, true);
request.send(null);
setTimeout('GetSwitchAnalogData()', 1000);
}
</script>
</head>
<body onload="GetSwitchAnalogData()">
<h1>Arduino AJAX Input</h1>
<div id="sw_an_data">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment