I have 5 javascript index.php functions:
1) showMsg(); //this display 50 latest messages
2) showPopUpBox(); // this I use jquery to load the textbox and send button from typingMsg.php
3) hidePopUpBox(); // this hide pop up box
4) checkNewMsg(); // this will be auto reloaded every 5 sec to check if there is new message, it will show the numbers counts of total new messages.
5) ShowNewMsg(); // this function will be called when the user click the "show new messages" button.
After the user enters the message in the text box in the pop-up window, after clicking the "Send" button, ajax will call messagePost.php to send the message to the database in the form of the following code:
$(function() {
$(".button").click(function() {
$.ajax({
type: "POST",
url: "messagePost.php",
data: dataString,
success: function() {
$('textarea.expand25-75').val('');
showMsg();
hidePopUpBox();
}
});
return false;
});
});
As you can see from the above codes, the showMsg () function; hidePopUpBox (); cannot be called because functions are not on this page, my question is: how to call a javascript function from another page?
source
share