March 2018
Beginner to intermediate
410 pages
10h 40m
English
Calling the actuator API is done slightly differently, since we use the POST method instead of the GET method. We need to send some content with the request. Sending text-based content is easy. We only need to send a string in the send() method. But we still need to set the Content-Type header to describe what type of text-based content we want to send. In our example, we use plain text:
var Span = document.getElementById("OutputState"); var CurrentState = Span.innerHTML; var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (xhttp.readyState == 4) { if (xhttp.status == 200) { var Data = JSON.parse(xhttp.responseText); Span.innerHTML = Data.output ? "ON" : "OFF"; } delete xhttp; ...Read now
Unlock full access