Skip to content

Instantly share code, notes, and snippets.

@maxschulze
Created May 5, 2017 18:13
Show Gist options
  • Save maxschulze/44ce3dbfbe9c6668aca5b82d84570e48 to your computer and use it in GitHub Desktop.
Save maxschulze/44ce3dbfbe9c6668aca5b82d84570e48 to your computer and use it in GitHub Desktop.
websocket = new WebSocket("ws://localhost:8080/");
websocket.onmessage = function(evt) {
$('#messages').append($('<li>').html(evt.data));
};
websocket.onerror = function(evt) {
$('#messages').append($('<li>').text('<span style="color: red;">ERROR:</span> ' + evt.data));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment