工具
This commit is contained in:
+22
-4
@@ -1,10 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<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:8080/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>
|
||||
Reference in New Issue
Block a user