I use below code for jQuery UI Autocomplete.
<script>
$(function() {
$( "#city" ).autocomplete({
source: function( request, response ) {
$.post('<?php echo base_url()?>records/get_village_street_town_name', {
SourceLanguage: 'SourceLanguage',
inputVal: $( "#city" ).val()
},
function (data) {
citydata = jQuery.parseJSON( data );
response(
$.each(citydata, function( index, city ) {
return city.cityname;
})
);
});
},
minLength: 2,
});
});
</script>
Below is the return O/P via the AJAX call.
[{"cityname":"ABCDE"},{"cityname":"ABDCE"},{"cityname":"ABEDC"}]
The problem is city textbox is not filled with citynames from the AJAX ? How can I fix this ?
I referred below two but didn't help.
$.mapinstead of$.each.dataan array of object