[英]loading jsp page into div
I want to load my jsp page in a div 我想在div中加载我的jsp页面
I have in my main js a table which has two column the first one is for the menu the second is for the div 我在主js中有一个表,该表有两列,第一列用于菜单,第二列用于div
I try without sucess with thsi code: 我尝试使用此代码成功:
<script src="/test/extjs/jquery-latest.min.js" type="text/javascript"></script>
<script src="/test/extjs/jquery.min.js" type="text/javascript"></script>
$(function() {
$('a').click(function() {
$('#divpage').load($(this).attr('href'));
return false;
});
});
<table width="100%" height="100%">
<tr>
<td width="10%" height="100%"><div id='cssmenu'>
<ul id="idGmenu">
<li style="display: none;><a href="#"><span>Home</span></a></li>
<li><a href="#"><span><spring:message code="taifSettingUP"/></span></a>
<ul>
<li class="current"><a href="/test/citizen.htm"><spring:message code="taifSettingCitizenUP"/></a></li>
<li><a href="/test/encodingType.htm"><spring:message code="taifSettingTypeUP"/></a></li>
</ul>
</li>
<li><a href='#'><span><spring:message code="taifCancellationsSuspensions"/></span></a>
<ul>
<li><a href="/test/cancellSuspension.htm"><spring:message code="taifCancellationsSuspensions"/></a></li>
</ul>
</li>
<li><a href='#'><span><spring:message code="taifConsultingUP"/> </span></a>
<ul>
<li><a href="/test/consultingOwner.htm"><spring:message code="taifConsultingOwnerUP"/></a></li>
<li><a href="/test/consultingDetailsUP.htm"><spring:message code="taifConsultingUPDetails"/></a></li>
</ul>
</li>
</ul>
</div></td>
<td width="90%" height="100%">
<div id="divpage"></div>
</td>
</tr>
</table>
the first js jquery-latest.min.js is for the css menu 第一个js jquery-latest.min.js用于CSS菜单
the second js jquery.min.js is for the loading jsp page into div 第二个js jquery.min.js用于将jsp页面加载到div中
Your jquery snippet is good. 您的jquery代码段很好。 Not fail-safe but working, just use it correctly (dont forget the <script></script>
tags... Try to avoid the unneccessary tags and tables. 不是安全的,但是可以正常工作,只是正确地使用它即可(不要忘记<script></script>
标记...尽量避免使用不必要的标记和表。
test.html 的test.html
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
$(function() {
$('a').click(function() {
$('#divpage').load($(this).attr('href'));
return false;
});
});
</script>
</head>
<body>
<ul>
<li><a href="#">NO CONTENT HERE!*</a></li>
<li><a href="a.html">Show me the SO site!</a></li>
</ul>
<div id="divpage">Content is coming!</div>
</body>
a.html a.html
<html><head></head><body><h1>Hello, i'm the a.html!</h1></body></html>
Have you tried returning an error.
$('#divpage').load($(this).attr('href'), function( response, status, xhr ) {
if ( status == "error" ) {
var msg = "Sorry but there was an error: ";
$( "#error" ).html( msg + xhr.status + " " + xhr.statusText );
}
});
Also, there is a
$(document).on("ajaxStop", function(){
});
this runs when all the ajax on the page is done. alternatively there is an event called ajaxComplete.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.