$(function () { // figure out where we need to connect to, and then do so var server = $('#connection').text(); var ws = new WebSocket(server); // Figure out where to log the connection status and setup the hooks to log // the current status. Also kick off the initial message to the device var lblStatus = $('#status'); ws.onopen = function () { lblStatus.text('Connected'); ws.send( JSON.stringify({ obj: "AV", num: 1 }) ); }; ws.onclose = function() { lblStatus.text('Disconnected'); }; ws.onerror = function(e) { lblStatus.text('Error: ' + e.data); }; // Parse incoming response and post it to the screen ws.onmessage = function (msg) { var res = JSON.parse(msg.data); if (res.type == "name") { $("