Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Help naman po Socket.io chat

ScreamAimsFire

Proficient
Advanced Member
Messages
228
Reaction score
13
Points
38
Bago lang po ako sa socket.io and sa sinusundan ko na tut sa youtube meron po akong hindi makitang mali. na everytime na mag sesend ako ng
chat wala po lumalabas. and ang prob po e Uncaught ReferenceError: jquery is not defined
.

index.html
Code:
<!DOCTYPE html>
<html>
<head>
	
	<title>Socket io Chat</title>
	<script src="http://code.jquery.com/jquery-latest.min.js"></script>
	<script src="/socket.io/socket.io.js"></script>
	
	<style>
	#chat {height: 500px;}
	</style>

</head>
<body>

	<div id="chat"></div>
		<form id=send-message>
		<input size="35" id="message"></input>
		<input type="submit"></input>
		</form>

	[B]<script>
		jquery(function($) {
			var socket = io.connect();
			var $messageForm = $('#send-message');
			var $messageBox = $('#message');
			var $chat = $('#chat');

			$messageForm.submit(function(e) {
				e.preventDefault();
				socket.emit('send message', $messageBox.val());
				$messageBox.val('');
			});	
	
			socket.on('new message', function(data){
				$chat.append(data + "<br/>");
			});
		});
	</script>[/B]

</body>
</html>

app.js
Code:
var express = require('express'),
	app = express(),
	server = require('http').createServer(app),
	io = require('socket.io').listen(server);

	server.listen(3000);
	console.log('Tumatakbo na yung Server mo...');

	app.get('/', function(req, res){
		res.sendFile(__dirname + '/index.html');
	});	

	io.sockets.on('connection', function(socket){
		socket.on('sendmessage', function(data){
		io.sockets.emit('newmessage', data);
	});
});

Sana po may makatulong sakin, maraming salamat po.
 
Bago lang po ako sa socket.io and sa sinusundan ko na tut sa youtube meron po akong hindi makitang mali. na everytime na mag sesend ako ng
chat wala po lumalabas. and ang prob po e Uncaught ReferenceError: jquery is not defined
.

index.html
Code:
<!DOCTYPE html>
<html>
<head>
	
	<title>Socket io Chat</title>
	<script src="http://code.jquery.com/jquery-latest.min.js"></script>
	<script src="/socket.io/socket.io.js"></script>
	
	<style>
	#chat {height: 500px;}
	</style>

</head>
<body>

	<div id="chat"></div>
		<form id=send-message>
		<input size="35" id="message"></input>
		<input type="submit"></input>
		</form>

	[B]<script>
		jquery(function($) {
			var socket = io.connect();
			var $messageForm = $('#send-message');
			var $messageBox = $('#message');
			var $chat = $('#chat');

			$messageForm.submit(function(e) {
				e.preventDefault();
				socket.emit('send message', $messageBox.val());
				$messageBox.val('');
			});	
	
			socket.on('new message', function(data){
				$chat.append(data + "<br/>");
			});
		});
	</script>[/B]

</body>
</html>

app.js
Code:
var express = require('express'),
	app = express(),
	server = require('http').createServer(app),
	io = require('socket.io').listen(server);

	server.listen(3000);
	console.log('Tumatakbo na yung Server mo...');

	app.get('/', function(req, res){
		res.sendFile(__dirname + '/index.html');
	});	

	io.sockets.on('connection', function(socket){
		socket.on('sendmessage', function(data){
		io.sockets.emit('newmessage', data);
	});
});

Sana po may makatulong sakin, maraming salamat po.

Hello Sir. I will impart you with a technique that is very useful for us software devs. Very Good Technique. Click Here

Possible cause of ReferenceError: jquery is not defined is when jquery is not properly imported in your webpage. So please check if the link you provided is working properly. Or maybe is was caused by a typo. Change jquery to jQuery. Or much better just use $(document).ready(function({ ... }); instead of jQuery(function(){ ... })
 
Hello Sir. I will impart you with a technique that is very useful for us software devs. Very Good Technique. Click Here

Possible cause of ReferenceError: jquery is not defined is when jquery is not properly imported in your webpage. So please check if the link you provided is working properly. Or maybe is was caused by a typo. Change jquery to jQuery. Or much better just use $(document).ready(function({ ... }); instead of jQuery(function(){ ... })

Love the LMGTFY

TS mas meron makakatulong sayo if you know how to google. It's a must skill nowadays
 
Hello Sir. I will impart you with a technique that is very useful for us software devs. Very Good Technique. Click Here

Possible cause of ReferenceError: jquery is not defined is when jquery is not properly imported in your webpage. So please check if the link you provided is working properly. Or maybe is was caused by a typo. Change jquery to jQuery. Or much better just use $(document).ready(function({ ... }); instead of jQuery(function(){ ... })

Love the LMGTFY

TS mas meron makakatulong sayo if you know how to google. It's a must skill nowadays

Salamat po sa mga reply mga sir, ive tried researching it first, of course before posting here and ask for help, that can help me and give some info that might related to my problem. And anyway i've figure it out. Thank you po
 
Last edited:
Back
Top Bottom