I got jQueryUI AutoComplete working. now I need to add another alert box, if there’s no result returned back. I want to say
alert("sorry, no data found");
I am not sure how to add it to my existing code.
$("#searchbox").autocomplete({
source: function (request, response) {
$.ajax({
url: "/Home/SearchIngredients",
dataType: 'json',
data: request,
success: function (data) {
response(data.map(function (value) {
return {
'label': value.Value,
'value': value.Value,
'id': value.Id
};
}));
}
});
},
minLength: 2,
select: function (event, ui) {
$("#searchItemId").val(ui.item.id);
$("#searchItemName").val(ui.item.value);
}
});
1 Answer