hotime/example/tpt/index.html

28 lines
777 B
HTML
Raw Normal View History

2017-08-17 02:37:00 +00:00
<!DOCTYPE html>
2018-04-08 16:02:13 +00:00
<html>
2017-08-17 02:37:00 +00:00
<head>
2018-04-08 16:02:13 +00:00
<meta charset="UTF-8"/>
<title>Sample of websocket with golang</title>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
$(function() {
2021-05-24 21:28:56 +00:00
var ws = new WebSocket("ws://localhost:80/app/index/websocket");
2018-04-08 16:02:13 +00:00
ws.onmessage = function(e) {
$('<li>').text(e.data).appendTo($ul);
};
var $ul = $('#msg-list');
$('#sendBtn').click(function(){
var data = $('#name').val();
ws.send(data);
});
});
</script>
2017-08-17 02:37:00 +00:00
</head>
<body>
2018-04-08 16:02:13 +00:00
<input id="name" type="text"/>
<input type="button" id="sendBtn" value="send"/>
<ul id="msg-list"></ul>
2017-08-17 02:37:00 +00:00
</body>
</html>