javascript - How to use jquery autocompleter with simple json? -
i using jquery autocomplete function serviceurl -
$('#locationsdiv').autocomplete({ serviceurl : '${pagecontext.request.contextpath}/pages/getlocationlist.do', paramname : "value", delimiter : ",", transformresult : function(response) { return { //must convert json javascript object before process suggestions : $.map($.parsejson(response), function(key,value) { return { value : key, data : value }; }) }; } });
in response of serviceurl got response -
{"1":"jaipur","2":"amer","3":"gurgaon"}
this json coming hashmap -
hashmap<string, string> locationmap = new hashmap<string, string>(); locationmap.put("1", "jaipur"); locationmap.put("2", "ajmer"); locationmap.put("3", "kolkata"); locationmap.put("4", "raipur"); locationmap.put("5", "rajasthan");
when using autocompleter, results coming search. , not sure json paramname
should sent filter result ?
Comments
Post a Comment