1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-10-05 19:18:01 +08:00
ULib/tests/examples/sse_example/index.html
2018-01-06 18:14:58 +01:00

25 lines
497 B
HTML

<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SSE example</title>
</head>
<body>
<h1>Stock Price</h1>
<script type="text/javascript">
function read_data() {
var stream = new EventSource('/get_ticker');
stream.onmessage = function(e){
document.getElementById('price').innerHTML=e.data;
};
stream.onerror = function(e){
console.log(e);
};
}
read_data();
</script>
<p>Price: <span id="price"></span></p>
</body>