Jquery 使用AJAX加载方法加载jsp页面
大家好,我需要一些关于ajax加载方法的帮助。基本上,当用户检查单选按钮时,我需要使用Ajax load()在主页面中显示jsp。我附上了需要显示jsp的页面的图片以及我的jsp代码。。请帮忙Jquery 使用AJAX加载方法加载jsp页面,jquery,ajax,Jquery,Ajax,大家好,我需要一些关于ajax加载方法的帮助。基本上,当用户检查单选按钮时,我需要使用Ajax load()在主页面中显示jsp。我附上了需要显示jsp的页面的图片以及我的jsp代码。。请帮忙 <div id="verification"> <p align=center class="4f1_title" ><u>Verification Decision</u></p> <table border="0
<div id="verification">
<p align=center class="4f1_title" ><u>Verification Decision</u></p>
<table border="0" cellpadding="0" cellspacing="0" align=center
width="100%">
<tbody>
<tr>
<td width="10%"></td>
<td width="8%">Passed <input id="passed" type="radio"
value="P" onclick="()"></td>
<td colspan="2" width="8%">Pending <input id="pending"
type="radio" value="H" onclick="()"></td>
<td width="9%">True Hit <input id="failed" type="radio"
value="F" onclick="()" disabled></td>
<td width="13%">Parcel Returned <input id="returned"
type="radio" value="S" onclick="()"></td>
<td width="23%">Referred to Law Enforcement <input id="law"
type="radio" value="L" onclick="()"></td>
<td width="8%">Retired <input id="retired" type="radio"
value="R" onclick="()" disabled></td>
<td width="12%">Return Reason <input id="ac"
type="radio" value="C" onclick="()"></td>
<td width="10%"></td>
</tr>
</tbody>
</table>
</div>
<br>
<div align=center>
<a href="javascript:handleClick()"><u>
<div id='showhidecomment'>Show Comments</div></u></a>
<div id='chkcomments'>
</div>
</div>
<br>
验证决定
通过
悬而未决的
真正的成功
退回的包裹
指执法部门
已退休的
返回原因
如果只想通过ajax加载页面,可以使用jquery加载:
还有jquery get:
您可以在文档中找到一个简单的示例
更新:
如果尚未添加jquery库的引用,则可能需要添加该库的引用。请参考下面的示例代码
简单页面显示“hello world”:
带按钮的页面。单击按钮时,它使用jquery load将上面的页面ajax加载到一个div容器中:
试试看
$(function() { // when DOM is ready
$("#showhidecomment").click(function(){ // when #showhidecomment is clicked
$("#chkcomments").load("sample.jsp"); // load the sample.jsp page in the #chkcomments element
});
});
并将您的html(链接部分)更改为
然后对它们应用单个处理程序
$('#verification').on('change','input[type="radio"][data-url]', function(){
if (this.checked){
var url = $(this).data('url');
$("#chkcomments").load( url );
}
});
所有这些
onclick=“()”
都是什么?你试过什么?您看过jQuery的列表了吗?很抱歉给您带来了混乱。。我以前试着用一个处理器来做这件事,但是我再也不能这样做了,我会把它移除。。到目前为止,我已经试过了,但不起作用$(document).ready(function(){$('#verification').find('#passed'){$(“radio”).click(function(){$(“#showhidecomment”).load(“sample.jsp”);{};谢谢@Gaby aka G.Petrioli,但是,当用户选择单选按钮而不是“showhidecomment”链接时,应该调用此函数。我将如何对复选框进行编码以实现这种功能?aka G.Petrioli,已通过,执法和返回原因。所有三个都加载不同的页面
<input id="passed" type="radio" value="P" data-url="some-page.jsp" />
<input id="law" type="radio" value="L" data-url="some-other-page.jsp" />
<input id="ac" type="radio" value="C" data-url="some-third-page.jsp" />
$('#verification').on('change','input[type="radio"][data-url]', function(){
if (this.checked){
var url = $(this).data('url');
$("#chkcomments").load( url );
}
});