nodejs终端:console.log无法打印

时间:2016-11-20 02:57:22

标签: node.js express

app.js

app.get('/',function(req,res){
  res.sendfile(__dirname + '/index.html');
  console.log('hhh');
});


io.sockets.on('connection',function(socket){
  socket.on('nickname',function(data){
    console.log('The sever received the following nickname: ' +data);
  });
});   

的index.html

<h1>Socket.IO Express Example</h1>


<form id="set-nickname">
      <label for="nickname">Nickname:</label>
      <input type="text" id="nickname">
      <input type="submit" value="submit">
   </form> 


<script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
   <script src="/socket.io/socket.io.js"></script>




<script type="text/javascript">
   var socket = io.connect();
    jQuery(function($){
         var nickName = $('#nickname');
         var setNacknameForm = $('#set-nickname');
         setNacknameForm.submit(function(event){
            event.preventDefalut();
            socket.emit('nickname',nickName.val());
         });
      });   
   </script>

hhh可以在终端browser打印,但我在浏览器中输入字词,点击submit,终端中没有打印任何内容。

我使用快递版本4.x

我该怎么办?

0 个答案:

没有答案