-
Notifications
You must be signed in to change notification settings - Fork 1
/
ajaxgpio.js
44 lines (37 loc) · 950 Bytes
/
ajaxgpio.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var xmlhttp = new XMLHttpRequest();
var current_time = updateIntervalsetting;
var updateInterval;
function update()
{
xmlhttp.open("GET", JSONurl, true);
xmlhttp.send();
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var myArr = JSON.parse(xmlhttp.responseText);
/*console.log(xmlhttp.responseText);*/
ProcessJSON(myArr);
}
}
function ProcessJSON(arr) {
var out = "";
for(i = 0; i < arr.length; i++)
{
document.getElementById("checkbox" + arr[i].gpio).checked = arr[i].state;
console.log("document.getElementById(\"checkbox" + arr[i].gpio + "\").checked = " + arr[i].state);
}
}
function loadXMLDoc(gpio)
{
var xmlhttp2;
if (window.XMLHttpRequest)
{
xmlhttp2=new XMLHttpRequest();
}
else
{
xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp2.open("GET", AJAX_Server + "/gpio=" + gpio,true);
xmlhttp2.send();
}