I've got some Node.js going on with some functions in the document ready of jQuery. I have two files both of which have a document ready. However, one file calls to the other, and it doesn't recognize the function. ReferenceError: SocketGameOut is not defined
=========== File 1 =============
$(document).ready( function () {
var socket = io.connect('http://local.baseball.com:3333');
socket.on('news', function (data) {
SocketBroadcastIn(data);
});
socket.on('message', function (data) {
SocketGameIn(data);
});
function SocketGameOut(outstring) {
socket.emit('clientData', outstring );
}
});
============ File 2 ==============
$(document).ready( function () {
$("#login").click( function () {
var loginData = { command: 'login', user: $("#user").val(), pass: $("#password").val() }
var data = JSON.stringify(loginData);
SocketGameOut(data); <--This function call returns
ReferenceError: SocketGameOut is not defined
});
});
document.ready, putwindow.SocketGameOut = SocketGameOut.