summaryrefslogtreecommitdiff
path: root/examples/src/main/resources/webpage/weather.js
blob: 8e95305a6f0505e87cd783d6ac39690143f13bf9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function WeatherJs(target) {
    var xhr = new XMLHttpRequest()

    xhr.open("GET",
        "http://api.openweathermap.org/data/" +
        "2.5/weather?q=Singapore"
    );

    xhr.onload = function (e) {
        if (xhr.status == 200) {
            var pre = document.createElement("pre");
            pre.textContent = xhr.responseText;
            target.appendChild(pre);
        }
    };
    xhr.send();
}