I have a Jetty 8 server running (hopefully soon with websockets).
If I want to send some data to the server with an ajax call, I can do this:
$.ajax({ ur
Just build the URL yourself:
var socket = new WebSocket("ws://" + location.host + "/whatever");
The location object is a property of the window object, and is therefore globally available.
To get only the host without the port, use location.hostname instead. If the websocket server listens on another port for example.
You can also inspect location.protocol to know if you should connect to wss (when https is used) or ws (when http is used).