26 lines
501 B
JavaScript
26 lines
501 B
JavaScript
|
function callURL(url)
|
||
|
{
|
||
|
var xmlhttp = new XMLHttpRequest();
|
||
|
xmlhttp.open("GET", url, true);
|
||
|
xmlhttp.send();
|
||
|
}
|
||
|
|
||
|
function getjson(url, handler_func)
|
||
|
{
|
||
|
var xmlhttp = new XMLHttpRequest();
|
||
|
xmlhttp.onreadystatechange = function () {
|
||
|
if(this.readyState == 4 && this.status == 200) {
|
||
|
var data = JSON.parse(this.responseText);
|
||
|
handler_func(data);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
xmlhttp.open("GET", url, true);
|
||
|
xmlhttp.send();
|
||
|
}
|
||
|
|
||
|
function getBME680Data(handler_func)
|
||
|
{
|
||
|
return getjson("/bme680.json", handler_func);
|
||
|
}
|