gpt4 book ai didi

jquery - 使用AJAX加载方法加载jsp页面

转载 作者:行者123 更新时间:2023-12-03 22:39:36 25 4
gpt4 key购买 nike

大家好,我需要一些关于ajax加载方法的帮助。基本上,一旦用户检查单选按钮,我需要使用 Ajax load() 在主页中显示 jsp。我已经附上了需要显示jsp的页面的图像以及我的jsp代码..请帮忙! web page

   <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>

最佳答案

尝试

$(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(链接部分)更改为

<div>
<div id='showhidecomment'>Show Comments</div>
<div id='chkcomments'></div>
</div>

由于 div 元素在 a 元素内无效。

<小时/>

更新评论

我会向这些元素添加自定义 data-url 属性(指定要加载的页面)

<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 );
}
});

关于jquery - 使用AJAX加载方法加载jsp页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14987391/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com