mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-12 16:36:38 +02:00
* started to implement POST api
* improved web serial console * added multi inverter total values (published through MQTT) * fixed: after boot there were transferred wrong data because of incorrect assignment (mqtt, visualization) -> not tested with sun
This commit is contained in:
parent
9e1b6be70e
commit
6bd7e01f1a
13 changed files with 404 additions and 379 deletions
|
@ -8,17 +8,19 @@ function toggle(name, hide) {
|
|||
elm.classList.remove('hide');
|
||||
}
|
||||
|
||||
function getAjax(url, ptr) {
|
||||
var http = new XMLHttpRequest();
|
||||
if(http != null) {
|
||||
http.open("GET", url, true);
|
||||
http.onreadystatechange = p;
|
||||
http.send(null);
|
||||
function getAjax(url, ptr, method="GET", json=null) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
if(xhr != null) {
|
||||
xhr.open(method, url, true);
|
||||
xhr.onreadystatechange = p;
|
||||
if("POST" == method)
|
||||
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
xhr.send(json);
|
||||
}
|
||||
function p() {
|
||||
if(http.readyState == 4) {
|
||||
if(null != http.responseText)
|
||||
ptr(JSON.parse(http.responseText));
|
||||
if(xhr.readyState == 4) {
|
||||
if(null != xhr.responseText)
|
||||
ptr(JSON.parse(xhr.responseText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue