Ajax calling to controller
Ajax calling to controller method
Sample Code:
Desc:
1.>onbutton click id = 'call' click, ajax() will call to states() method that defined in controller class .
and getting response into 'Result' variable object and putting response into divID of <div> tag into body .
<script type="text/javascript">
$(document).ready(function() {
$('#call').click(function () //'call is an ID of UI comp';
{
$.ajax({
type: "post",
url: "./states", //Controller method
data: “cname”:india,
success: function(Result){
$('#divID).append(Result);
}
});
});
});
</script>
<title>Jsp file</title>
</head>
<body>
input:<input id="cname" type="text" name=" cname " value="" /><br></br>
<input type="button" name=" " value=”” id="call"/>
<div id="DivID"></div>
</body>
Sample Code:
Desc:
1.>onbutton click id = 'call' click, ajax() will call to states() method that defined in controller class .
and getting response into 'Result' variable object and putting response into divID of <div> tag into body .
<script type="text/javascript">
$(document).ready(function() {
$('#call').click(function () //'call is an ID of UI comp';
{
$.ajax({
type: "post",
url: "./states", //Controller method
data: “cname”:india,
success: function(Result){
$('#divID).append(Result);
}
});
});
});
</script>
<title>Jsp file</title>
</head>
<body>
input:<input id="cname" type="text" name=" cname " value="" /><br></br>
<input type="button" name=" " value=”” id="call"/>
<div id="DivID"></div>
</body>
Comments
Post a Comment