I get data from the ajax but i want to make with jquery autocomplete.
I fill the name in the text box using autocomplete.
data from the ajax
{
"id": "2",
"name": "Jenny Doe",
"phone": "",
"email": "elsa@arendelle",
"password": null,
"registered": "2014-04-11 15:06:02",
"address": "",
"email_subscription": "0",
"email_verified": "0",
"reset_password": null,
"facebook_uid": null,
"title": "",
"phone2": "",
"gender": null,
"booking_date": "0000-00-00",
"birthday": "0000-00-00",
"nationality": "",
"passport": ""
},
I want to show the name of customer when i click in the input box. And i wonder how to fix this problem using the ajax and auto complete.
Jquery Code
$('.customer').on('click', '.customer_name', function(){
var name = $(this).val();
var customer_url = '/api/users?name_fulltext' + name;
console.log(customer_url);
$.getJSON( customer_url, function( data ){
customer_cache[name]= [];
for (var j in data ) {
//index the results by id
customer_cache[name][data[j]["name"]] = data[j];
var customer_name = customer_cache[name][data[j]["name"]];
}
});
$('.customer_name').autocomplete({
});
});