javascript - I called Socket.io function and Uncaught TypeError: undefined is not a function -


i'm making socket.io chat application, , got trouble @ javascript.

this javascript file (client)

<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script> $(document).ready(function() {      // make new chat div      $("#topic_button").click(function(e) {         e.preventdefault()         var domelement = $('<div class="content"><div class="messages"><ul class = "other_message" class="title"><h3>'+$("#m").val()+'</h3></ul>'+'상대방'+'<div class="my_message">'+'내메시지' +'</div></div><div class="type_div"><form action="" class="chat_form" onsubmit="event.preventdefault();"><input autocomplete="off" /><button class="chat_button">send</button></form></div></div>');         $("#content").after(domelement);     });       // create new category     $("#topic_button").click(function(e){         var $item = $('<div class="item_div"><li>' + $("#m").val() + '</li><button class="item_button">x</button><div></div></div>')         $('#category').append($item);         $('#m').val('');      });      // delete category     $("#category").on("click", ".item_button", function () {         var title = $(this).prev().html();         $( "h3:contains("+title+")" ).parents(".content").remove();         $(this).parent().slideup();     });    var socket = io();    $('body').on("submit", ".chat_form", function(){     socket.emit('chat message', $('.chat_form').firstchild().val());     $('.chat_form').firstchild().val('');     return false;   });     socket.on('chat message', function(msg, reply){     $('.other_message').append($('<li>').text(reply + ': ' + msg));   });   socket.on('test channel', function(msg, sender){     $('.my_message').append($('<li>').text(sender + ': ' + msg));   });  });    </script> 

and at

$('body').on("submit", ".chat_form", function(){ socket.emit('chat message', $('.chat_form').firstchild().val()); $('.chat_form').firstchild().val(''); return false; }); 

" socket.emit('chat message', $('.chat_form').firstchild().val()); " brings uncaught typeerror: undefined not function

and think javascript problem. me?


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -