0

我有一个 header.js,在其就绪部分中包含以下内容:

    var auto_refresh = setInterval(function () {
        var theToken = $('#token').text();
        $('#error-div').text('');
        $('#load_me').load("http://localhost:8080/sc_demo/tasklist.jsp?app=Home&process=tasklist&userToken="+theToken
            ).fadeIn("slow");                
}, 30000); // autorefresh the content of the div after every 3000 milliseconds(30sec)  

现在,它加载的页面“tasklist.jsp”被加载到当前页面的一个 div 中,并且应该每 30 秒刷新一次。tasklist.jsp 具有需要服务的“点击”事件,并由 header.js 中的点击事件处理。为了让这些工作正常,即使 tasklist.jsp 被加载到已经包含 header.js 的页面中,我也必须在 tasklist.jsp 中包含 header.js。然而,这会导致级联重载。我该如何防止这种情况?尝试体面的代码重用真的不可能吗?如果 header.js 应该已经在我加载我的部分的页面中,为什么我还需要包含它?

4

0 回答 0