diff options
Diffstat (limited to 'examples/src/main/resources/webpage/weather.js')
-rw-r--r-- | examples/src/main/resources/webpage/weather.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/examples/src/main/resources/webpage/weather.js b/examples/src/main/resources/webpage/weather.js new file mode 100644 index 0000000..8e95305 --- /dev/null +++ b/examples/src/main/resources/webpage/weather.js @@ -0,0 +1,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(); +}
\ No newline at end of file |