我想创建一个“类似门户”的应用程序与HeadContainer应用程序(基本上是EAR)有一个HTML页面。这个HTML页面有2个div。每个div再次是一个EAR - 每个div加载该EAR即应用程序。假设他们是AppChild1和AppChild2。jQuery和div加载
我在HeadContainer JavaScript的使用jQuery负荷加载AppChild1和AppChild2。
当我尝试在AppChild1提交表单我做使用jQuery AJAX的一个岗位。这是AppChild1应用程序中的外部JavaScript文件。比方说,文件名是scriptFile1.js
萤火虫让我发现,它试图找到HeadContainer的CONTEX这是不对的下scriptFile1.js。
当我将鼠标悬停在Firebug的形式中HeadContainer - 它显示AppChild1形式和标题,但AppChild1所包含的脚本文件是完全丢失。
有人可以解释怎么回事错在这里?
OK,因为几个你想要的代码,我会给出代码结构。
The HeadContainer EAR structure is like this
HeadContainer has a html called Main.html
**Main.html**
----------------
<html>
<head><title>Main Page</title>
<script lanuage="text/javascript">//Include jQuery library </script>
</head>
<body>
<form name="MainForm" id="MainId">
<div name="div1" id="div1"/><br />
<div name="div2" id="div2" /><br />
<input type="submit" id="MainSubmit" />
</form>
</body>
</html>
Main.html has an asscociated javascript file main.js
$(document).ready(function() {
$("#div1").load(div1url,function(){
//load function call back implementation
});//Close load
$("#div2").load(div1url,function(){
//load function call back implementation
}); //Close load
});//doc.ready closing
//AppChild1 is a EAR which is loaded into div1
//AppChild1 has a html div1.html and a associated scriptFile1.js file.
//It is this js file which is not getting loaded
**div1.html** is like this
<html>
<head><title>Div1 Page</title>
<script lanuage="text/javascript">//Include jQuery library </script>
</head>
<body>
<form name="div1Form" id="div1Id">
<input name="txtName1" id="txtname1"/><br />
<div name="txtName2" id="txtName2" /><br />
<input type="submit" id="div1Submit" />
</form>
</body>
</html>
**scriptFile1.js**
$(document).ready(function() {
$("#div1Submit").submit({
$.ajax({
data: $("#div1Form").serialize(),
url : "/someServlet",
success:function(response){
//load the next screen with values from the response object.Response is a
//json object.
}
});
}); //Close Submit
});//doc.ready closing
//The AppChild2 is also on the similar lines
//When I load the Main.html in Firebug - it looks for scriptFile1.js file under the //HeadContainer which is not correct. scriptFile1.js is under AppChild1 EAR. This is //happening at the load of the main page.
//当我viewsource的DIV1如果显示窗体和标题,但包括// JavaScript文件scriptFile1.js丢失
这不是答案,从这里删除,并写在评论下面的问题,否则人会downvote你 – diEcho 2011-03-10 04:58:23