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

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

Verification Decision

Passed Pending True Hit Parcel Returned Referred to Law Enforcement Retired Return Reason


尝试

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

 
Show Comments

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


更新 评论

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

    

然后对它们应用单个处理程序

 $('#verification').on('change','input[type="radio"][data-url]', function(){ if (this.checked){ var url = $(this).data('url'); $("#chkcomments").load( url ); } }); 

如果您只想加载页面,可以使用jquery加载: http : //api.jquery.com/load/

还有jquery获取: http : //api.jquery.com/jQuery.get/

您可以在文档中找到一个简单的示例。

更新:

如果尚未添加对jquery库的引用,则可能需要添加引用。 请参阅下面的示例代码。

简单页面显示’hello world’: http : //jsbin.com/ivinuw/1/

带按钮的页面。 单击按钮时,它使用jquery加载到ajax将上面的页面加载到div容器中: http : //jsbin.com/ubitat/1/edit