I am having a great deal of trouble getting autocomplete to work on my page. When I enter 2 characters (\"OW\") into my search input, I get the preloader image (see below),
It was a long road, but after many hours of experimenting I came up with this code:
$("#searchInput").autocomplete({
source: function (request, response) {
$.ajax({
url: '@Url.Action("GetKeywords", "Home")',
dataType: "json",
data: {
SearchTerm: request.term
},
success: function (data) {
var parsed = JSON.parse(data);
var newArray = new Array(parsed.length);
var i = 0;
parsed.forEach(function (entry) {
var newObject = {
label: entry.kwrdKeyWord
};
newArray[i] = newObject;
i++;
});
response(newArray);
},
error: function (message) {
response([]);
}
});
},
minLength: 2
});
This appears to work fine. The truth is my keywords are unique, so I can live without the ID anyway.