try this
(function () {
var url = "http://localhost:61397/CompanyRestService.svc/GetCompID/0";
var items = [];
$.getJSON(url)
.done(function (data) {
$.each(data, function (i, item) {
items[i] = item.Name;
});
$('#select').autocomplete( {
source: items,
select: function (event, ui) {
var value = ui.item.value;
var id = '';
for (var i = 0; i < data.length; i++) {
if (value == data[i].Name) {
id = data[i].Id;
break;
}
}
$("#selectID").html(id);
return false;
}
}
);
});
})();