Load jsp page using AJAX download method

Hi everyone, I need help using the ajax download method. Basically I need to use Ajax load () to display jsp on the main page after the user checks the switch. Ive attached the image of the page where jsp should be displayed, as well as my jsp code .. Please help! 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> 
+6
source share
2 answers

Try

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

And change your html (part of the link) to

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

Since div elements are not allowed inside a elements.


update for comments

I would add a custom data-url attribute to these elements (to indicate the page to load)

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

and then apply one handler to them

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

If you just want to load ajax to a page, you can use jquery download: http://api.jquery.com/load/

There is also jquery get: http://api.jquery.com/jQuery.get/

You can find a simple example in the documentation.

Update:

You may need to add a link to the jquery library if you have not already done so. See the sample code below.

A simple page displays hello world: http://jsbin.com/ivinuw/1/

Page with button. When you click the button, it uses jquery loading to load the ajax page above into the container div: http://jsbin.com/ubitat/1/edit

+2
source

All Articles