have 2 lists, I tried to retrieve the values of lookup field (one or more values from the Finance list (Title, Country (lookup field to the list Country column "Title"
$("#Finance").autocomplete({
minLength: 2,
source: function(request, response) {
var term = request.term;
var restUrl = "/_api/web/lists/GetByTitle('Finance')/items?$select=Title,Pays/Country&$expand=Country/Title&$filter=substringof('" + term + "',Title)";
$.ajax({
contentType: "application/json;odata=verbose",
headers: { "accept": "application/json;odata=verbose" },
url: restUrl,
dataType: 'json',
async: false,
cache: false,
beforeSend: function() {
console.log("beforeSend");
},
success: function(data) {
response($.map(data.d.results, function(value, key) {
return {
label: value.Title,
value: value.Title,
country: value.Country,
value: value.Country
};
}));
},
error: function(data) {
alert('Erreur');
},
complete: function() {
console.log("complete");
}
});
},
// Run this when the item is in focused (not selected)
focus: function(event, ui) {
return false;
},
// Run this when the item is selected
select: function(event, ui) {
$("#Country").val(ui.item.label);
$("#Finance").val(ui.item.Country);
return false;
},
});
});
the result is [object] [object], [object] [object]