Autocomplte/aJax-java help
Hi, I am new to jQuery and trying to use autocomplete widget with ajax call to database.
I am able to call database, returned ArrayList of string value, and converted the response as json object using org.codehaus.jackson.map.ObjectMapper( Do I need to use something else?). When i put an altar, I can see results as pure strings with comma delimiter, but not able to see a suggestion list with auto complete. Could someone take a look and suggest me how to correct it. Appreciate your help. Thanks!
//Java code tha treturns the jason obejct using org.codehaus.jackson.map.ObjectMapper.
response.setContentType("application/json");
response.setHeader("cache-control", "no-cache");
ArrayList polNo = doa.getPolicyData(ajaxForm.getPolicyNumber());
ObjectMapper mapper = new ObjectMapper();
OutputStream out = response.getOutputStream();
mapper.writeValue(out, polNo);
in JavaScript:
$( "#policyNumber" ).autocomplete({
source: function (request,response){
$.ajax({
type: "POST",
url: "/NB/AjaxSubmit.do",
dataType: "json",
data: {policyNumber: request.term},
success: function (data) {
alert(data);
}
});
},minLength: 3
});
//alert data showing as :
TMA412732,TMA412733,TMA412734