title: websocket in javascript - displaying error in console
body: <p>I am very new to websocket and started working WS in javascript and thinking to integrate this websocket later with dojo.</p>
  
  <p>This is my code</p>
  
  <p>I am using MAMP as local server, I can access my localhost using 'http:// localhost' and http:// localhost:80</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;script type="text/javascript"&gt;
              var connection = new WebSocket('ws://localhost', 'json');
           connection.onopen = function () {
             console.log('Connection Opened');
           };
           connection.onerror = function (error) {
             console.log('WebSocket Error ' + error);
           };
           connection.onmessage = function (e) {
             if(e.data.indexOf("subProtocol")==-1)
               document.getElementById("response").innerHTML=e.data+"&lt;br/&gt;";
           };
           function sendMessage(msg){
             connection.send(msg);
           }
     &lt;/script&gt;
     &lt;/head&gt;
     &lt;body&gt;
        &lt;h1&gt;WebSocket Echo Client&lt;/h1&gt;
        &lt;button&gt;
           Send Hello
        &lt;/button&gt;
     &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I am getting the following ERROR in console
  WebSocket connection to 'ws://localhost/' failed: Error during WebSocket handshake: Unexpected response code: 200 client.html:4
  WebSocket Error [object Event] </p>
  
  <p>Thanks,
  Mo</p>