$(function ()
{
  var socket = new WebSocket('ws://localhost/stockprice');
 
  // oczekiwanie na otwarcie gniazda 
  socket.onopen = function ()
  {
    socket.send(JSON.stringify(
    {
      ticker: "ibm"
    }));
  };
  socket.onmessage = function (msg)
  {
    var prices = $.parseJSON(msg.data);
    var html = "IBM: " + prices.ibm;
    $('div.prices').html(html);
  }
});