Well, I'm trying to implement the autocomplete of the jQuery UI in my code, but in a partial way it does not work as it does not display the options below the input . It performs the request correctly, but when the options are displayed on the screen it is blank. I'm pretty sure that's the way I'm sending my JSON to the source attribute of the plugin .
Below are the codes:
The Input
<div class="ui-widget">
<input id="first-name" placeholder="Primeiro Nome" name="firstName" type="text" class="form-control"/>
</div>
JS Code
$(document).ready(function () {
$(function () {
$("#first-name").autocomplete({
source: function (request, response) {
$.ajax({
url: "${pageContext.request.contextPath}/auth/getCustomerAJAX",
type: "GET",
data: {
paramName: request.term
},
dataType: "json",
success: function (data) {
var obj = JSON.parse(data);
alert(obj);
response(obj.firstName);
}
});
}
});
});
});
The callback
[
{
"idCustomer":1,
"tenantId":null,
"birthDate":null,
"email":"[email protected]",
"firstName":"j",
"gender":"\u0000",
"lastName":"Galao Bonin",
"document":null,
"customerPhone":null,
"passenger":null,
"customerAddress":null,
"observations":null,
"customerService":null
}
]