forked from golang/hotime
28 lines
777 B
HTML
28 lines
777 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<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() {
|
|
var ws = new WebSocket("ws://localhost:80/app/index/websocket");
|
|
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>
|
|
</head>
|
|
<body>
|
|
<input id="name" type="text"/>
|
|
<input type="button" id="sendBtn" value="send"/>
|
|
<ul id="msg-list"></ul>
|
|
</body>
|
|
</html> |