49
rated 0 times
[
53]
[
4]
/ answers: 1 / hits: 14368
/ 11 Years ago, mon, february 24, 2014, 12:00:00
Here is my relevant codes.my out put is like this.
I need to send region and tsrId as parameters to query.
here is my code
jsp
Here is my ajax request with jquery
<script type=text/javascript>
$(document).ready(function() {
var region = document.getElementById('region').value;
var tsrId = document.getElementById('tsrId').value;
$('#tsrId').autocomplete({
serviceUrl: 'getTsrId.html',
data: ({queryData : {region:region,tsrId:tsrId}}),
//delimiter: ,,
transformResult: function(response) {
return {suggestions: $.map($.parseJSON(response), function(item) {return { value: item.name, data: item.id };
})};}});});
</script>
here is the HTML form
<td>Region</td>
<td><input type=text name=region id=region><div class=autocomplete-suggestions></div></td>
<td>TSR ID</td>
<td><input type=text name=tsrId id=tsrId maxlength=8><div class=autocomplete-suggestions2></div></td>
here is my controller
@RequestMapping(value = /getTsrId, method = RequestMethod.GET)
public @ResponseBody List<TSRMaster> getTsrId(@RequestParam String tagName,@RequestBody QueryData queryData) {
List<TSRMaster> tsrMasterList=new ArrayList<TSRMaster>();
tsrMasterList=gpsdao.getTsrIdList(queryData.getRegion(),queryData.getTsrId());
return tsrMasterList;
}
here is my bean class for requestMapping
public class QueryData {
private String region;
private String tsrId;
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getTsrId() {
return tsrId;
}
public void setTsrId(String tsrId) {
this.tsrId = tsrId;
}
}
Please help me to sort out this issue..is there any other alternative solution, please mention that path below
thanks.
More From » jquery