View Single Post
coderus's Avatar
Posts: 6,436 | Thanked: 12,700 times | Joined on Nov 2011 @ Ängelholm, Sweden
#76
inside main.qml declare:
Code:
function controlLamp(endpoint) {
  var xmlhttp = new XMLHttpRequest()
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
      console.log(endpoint)
    }
  }
  xmlhttp.open("POST", "http://192.168.0.222/" + endpoint)
  xmlhttp.send()
}
and call anywhere you want like:
Code:
MouseArea {
    anchors.fill: brightUp
    onClicked: {
        controlLamp("lightup")
    }
}
__________________
Telegram | Openrepos | GitHub | Revolut donations
 

The Following 5 Users Say Thank You to coderus For This Useful Post: