gadgetyWebServer/index.html
2018-08-03 20:21:31 +02:00

37 lines
1 KiB
HTML

<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>Random generator</title>
<style>
/*=======================COMUNE=====================*/
html{
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<h2>Random number generator (hurray!)</h2>
<input type="button" value="Generate" onclick="receive_random()">
<p id="value">Press to generate new value</p>
<script type="text/javascript">
function receive_random() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200) {
var result = JSON.parse(this.responseText);
console.log(result);
document.getElementById("value").innerHTML = result.val;
}
};
xmlhttp.open("GET", "/random.ws", true);
xmlhttp.send();
}
</script>
</body>
</html>