title: Web browser never stops 'loading' when connecting to socket.io server?
body: <p>I am having an issue with socket.io. I have a nodejs server that's acting as a webserver while also running a socket.io server. Additionally I have a webpage that connects to the socket.io server. The web page has one button that when clicked, emits a time update request. The socket.io server then sends back the time in milliseconds to the webpage which then updates a div to display the time.</p>
  
  <p>This works fine, however, I've noticed that my web browser (Chrome) has the spinning loading icon in the tab and acts like the web page has never fully loaded. It also displays the 'X' to stop loading a page.</p>
  
  <p>If I click the 'X' to stop loading the page, my software continues to work fine, but I cannot figure out why the page never completely loads.</p>
  
  <p>Server Code:</p>
  
  <pre><code>var http = require("http");
  var wrHandler = require("./webRequestHandler");
  var io = require("socket.io");
  var parser = require("./messageParser");
  
  function start() {
      function onRequest(request, response){
          wrHandler.handle(request, response);        
      }
  
      var webserver = http.createServer(onRequest).listen(8888);
      console.log("Server has started.");
  
  
  
      var ioserver = io.listen(webserver);
      ioserver.set('log level', 3);
      ioserver.sockets.on('connection', function(socket){
          parser.parse(socket);
      });
  
  }
  
  exports.start = start;
  </code></pre>
  
  <p>Web Request Handler:</p>
  
  <pre><code>var url = require("url");
  var fs = require("fs");
  
  function handle(request, response){
      var pathname = url.parse(request.url).pathname;
      console.log(pathname);
  
          switch(pathname){
              case '/':
                  fs.readFile("../html/index.html", function(error, data){
                      if(error){
                          response.writeHead(404);
                          response.write("This file does not exist.");
                      }
                      else{
                          response.writeHead(200, {"Content-Type": "text/html"});
                          response.write(data, "utf8");
                      }
                  });
                  break;
              default:
                  fs.readFile("../html" + pathname, function(error, data){
                      if(error){
                          response.writeHead(404, {"Content-Type": "text/html"});
                          response.write("&lt;html&gt;&lt;body&gt;This file does not exist!&lt;/body&gt;&lt;/html&gt;");
                          console.log("Test");
                      }
                      else{
                          response.writeHead(200, {"Content-Type": "text/html"});
                          response.write(data, "utf8");
                      }
                  });
          }
  }
  
  exports.handle = handle;
  </code></pre>
  
  <p>Message Parser:</p>
  
  <pre><code>function parseMessage(socket){
      socket.on('client_msg',function(data){
          var msgID = data.msgID;
  
          switch(msgID){
              case "gettime": 
                  socket.emit('timeupdate', {"time": new Date().getTime()});
                  break;
              default: break;
          }
      });
  }
  
  exports.parse = parseMessage;
  </code></pre>
  
  <p>HTML Page:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"&gt;&lt;/script&gt;
          &lt;script&gt;
              var socket = io.connect();
  
              function getTime(){
                  socket.emit('client_msg', {"msgID": "gettime"});
              }
  
              socket.on('timeupdate', function(data){
                  $("#time").text(data.time);
              });
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
          &lt;input type="button" value="Get Server Time" onclick="getTime()"/&gt;
          &lt;div id="time"&gt;
  
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I should admit that I'm very new to node.js and not the strongest javascript developer either. Any criticism/advice/hints are greatly appreciated.</p>