-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
33 lines (33 loc) · 1.16 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html>
<head>
<script src="http://cdn.jsdelivr.net/jquery/2.0.3/jquery-2.0.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
window.WebSocket = window.WebSocket || window.MozWebSocket;
var websocket = new WebSocket('ws://127.0.0.1:9000');
websocket.onopen = function () {
$('h1').html('Connected!');
};
websocket.onerror = function () {
$('h1').html('Error Connecting!');
};
websocket.onmessage = function (message) {
$('div').append(message.data + "<br />");
};
$('button').click(function(e) {
e.preventDefault();
websocket.send($('input').val());
//websocket.send("list");
$('input').val('');
});
});
</script>
</head>
<body>
<h1>WebSocket Status</h1>
<input type="text" />
<button>Send Test Message</button>
<div></div>
</body>
</html>