March 2018
Beginner to intermediate
410 pages
10h 40m
English
We will call our /Momentary API in two ways. First, we will update the gauge on the screen. This is done by resetting the src property on the IMG tag of the gauge. To make sure the browser reloads the image, we add a query parameter that is unique, but not used by the API. Since it is an IMG tag, the browser will automatically add an Accept header field, telling the resource it wants an image. Code is straightforward:
var Images = document.getElementsByTagName("IMG");
Images[0].src = "/Momentary?TP=" + Date();
For updating the table, we use an XMLHttpRequest object. Here, we must manually set the Accept header to make sure we get the representation we desire. We need to follow the process. When we ...
Read now
Unlock full access