[url]https://github.com/pwarelis/Ajax-Typeahead[/url]
$("#ajax-typeahead").typeahead({
ajax: {
url: "/path/to/source",
timeout: 500,
displayField: "name",
triggerLength: 1,
method: "get",
loadingClass: "loading-circle",
preDispatch: function (query) {
showLoadingMask(true);
return {
search: query,
otherParam: 123
}
},
preProcess: function (data) {
showLoadingMask(false);
if (data.success === false) {
// Hide the list, there was some error
return false;
}
// We good!
return data.mylist;
}
}
});