Hello,
I have a question that concerns calling a function within another js sourcefile.
I declared the sourcefile before the file with the function that calls that particular function. I thought this would work, but it gives an undefined error.
I also have a function in a file that calls a function in a later declared sourcefile. That would concern the same files but the other way around.
The functions are declared between document ready statements(functions).
Is there a way to avoid the undefined error??
this is how I set it up:
<script type="text/javascript" src="includes/livetabs.js"></script>
<script type="text/javascript" src="includes/chat.js"></script>
//this is in the chat.js file
$(document).ready(function(){
function chatWith(chatuser) {
check=iscookieUsername();
if (!check){
chatusersuspended=chatuser;
showchatinlogform();
}
createChatBox(chatuser);
$("#chatbox_"+chatuser+" .chatboxtextarea").focus();
}
});
//this is in the livetabs.js file
$(document).ready(function(){
function iscookieUsername(){
if (!tbusername){
return false;
}
if (issessionusername){//flag if session has already been set
return true;
}
$.ajax({
url: "includes/livetabs.php",
data: ({username: tbusername, action: "setsessionusername"}),
cache: false,
type: "POST",
dataType: "json",
success: function(data) {
//store username in php session
//some personal user preferences returned
usernamecookie=data.cookie;
trackuser=data.track;
issessionusername=1;
}});
return true;
}
});
Thanks, Richard