Jquery jsp中的ready函数和js文件中的ready函数

Jquery jsp中的ready函数和js文件中的ready函数,jquery,Jquery,我在jsp中有一个ready函数,在javascript中也有一个ready函数。我在理解事情的运行顺序时遇到了一些问题 在我的jsp中我有 <head> <script type="text/javascript"> $().ready(function() { var params = ({ reportingManagerTitle : "<spring:message code='title.repor

我在jsp中有一个ready函数,在javascript中也有一个ready函数。我在理解事情的运行顺序时遇到了一些问题

在我的jsp中我有

<head>
    <script type="text/javascript">
    $().ready(function() {
        var params = ({
            reportingManagerTitle : "<spring:message code='title.reportingManager'/>",
            launchButtonText: "<spring:message code='button.launch'/>"          
        });
    init(params);
    }); 
    </script>       
    <script type="text/javascript" src="<c:url value="resources/js/pages/login.js" />"></script>    
</head>
我的问题是reportingManagerTitle和launchButtonText都未定义。我将首先在js中运行javascript,然后在外部文件中运行js。我做错了什么


谢谢

您是否试图在init函数之外使用该变量?如果是,则不能这样做,因为它们是函数的变量,除非首先在函数外部将它们声明为全局变量。并且不要忘记,如果您试图在$ready之外使用em,那么这可能不会有帮助。检查“对不起,我忘了添加变量声明”。它们在js文件的顶部声明为globalsNow,您将它们声明为globals,并在另一个$.ready中使用它们,这样应该可以工作。一定还有别的事。你确定你没有拼写错误的变量名或什么吗?嗯,好的。这基本上就是我已经做过的。有趣的是,我的代码在Tomcat6上工作,但当我在WebSphere6.1上部署时,它就不工作了。我在init和警报上设置断点。警报总是首先运行,这就是为什么我认为我的排序可能会出现问题。能否在主文档脚本和函数中尝试$window.load而不是$ready?
var reportingManagerTitle = null;
var launchButtonText = null;
$().ready(function() {
    // do something with reportingManagerTitle after page load
    alert(reportingManagerTitle );

    // so something with launchButtonText after page load
    alert(launchButtonText );
});

function init(params) { 
    reportingManagerTitle = params.reportingManagerTitle;
    launchButtonText = params.launchButtonText;
}