Hello everyone I need some help with ajax load method. Basically I need to use Ajax load() to display a jsp within the main page once user checks the radio button. Ive att
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 (the link part) to
Show Comments
Since div
elements are invalid inside a
elements.
update for comment
I would add a custom data-url
attribute to those elements (to specify the page to load)
and then apply a single handler to them
$('#verification').on('change','input[type="radio"][data-url]', function(){
if (this.checked){
var url = $(this).data('url');
$("#chkcomments").load( url );
}
});