mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
Make the front-end to throttle the request by 100ms
This commit is contained in:
parent
4afc4d0751
commit
220ba0785c
@ -1,7 +1,15 @@
|
||||
var request = null;
|
||||
var timeoutID = null;
|
||||
|
||||
$('#search').on('input', function () {
|
||||
var query = $(this).val();
|
||||
var timeoutMs = 100;
|
||||
|
||||
if (timeoutID !== null) {
|
||||
window.clearTimeout(timeoutID);
|
||||
}
|
||||
|
||||
timeoutID = window.setTimeout(function () {
|
||||
request = $.ajax({
|
||||
type: "POST",
|
||||
url: "query",
|
||||
@ -54,6 +62,7 @@ $('#search').on('input', function () {
|
||||
}
|
||||
},
|
||||
});
|
||||
}, timeoutMs);
|
||||
});
|
||||
|
||||
// Make the number of document a little bit prettier
|
||||
|
Loading…
Reference in New Issue
Block a user