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() }
MouseArea { anchors.fill: brightUp onClicked: { controlLamp("lightup") } }