我有5周JavaScript函数的index.php:如何从其他页面调用Javascript函数?
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.
在用户键入m之后对再后,他点击“发送”的弹出框的文本框中essage按钮,阿贾克斯将调用messagePost.php提交邮件数据库,如下面的代码:
$(function() {
$(".button").click(function() {
$.ajax({
type: "POST",
url: "messagePost.php",
data: dataString,
success: function() {
$('textarea.expand25-75').val('');
showMsg(); //this is my problem
hidePopUpBox(); //this is my problem too
}
});
return false;
});
});
为u可以从看代码如上,showMsg()的功能; hidePopUpBox();不能被称为,因为功能不在这个页面上,我的问题是如何从不同的页面调用JavaScript功能?
我能问你为什么不把你的可重用的JavaScript功能.js文件,并采取refrence在每一页ü需要使用它的功能? 还是做这个功能Server Business与index.php页面有关? – Marwan 2011-05-03 11:45:33
'如何从不同的页面调用javascript函数?'和什么是不同的页面? – epascarello 2011-05-03 11:46:31
该功能在该范围内是否可见?阿贾克斯是否成功?另一件事是,其他页面是否可以调用,或者你是否正确地将它添加到当前页面?像'' – ace 2011-05-03 11:50:30