I want to auto load the text box with some database values. I tried with following code but not getting the values for autocomplete. I used firebug to debug the script but neither it is showing error nor I am getting results. Here is the code-
<script src="js/jquery1.10.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script>
$('#userlist').autocomplete({
source: function( request, response ) {
//alert('hi')
$.ajax({
url : 'ajax.php',//?action=getUsers',
dataType: "json",
data: {
name_startsWith: request.term,
type: 'users'
},
success: function( data ) {
//alert('in');
response( $.map( data, function( item ) {
return {
label: item,
value: item
}
}));
}
});
},
autoFocus: true,
minLength: 0
});
</script>
<form action="search_result.php" name="searchform" method="post">
<input id="userlist" type="text" class="form-control txt-auto"/>
</form>