mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 23:04:26 +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 request = null;
|
||||||
|
var timeoutID = null;
|
||||||
|
|
||||||
$('#search').on('input', function () {
|
$('#search').on('input', function () {
|
||||||
var query = $(this).val();
|
var query = $(this).val();
|
||||||
|
var timeoutMs = 100;
|
||||||
|
|
||||||
|
if (timeoutID !== null) {
|
||||||
|
window.clearTimeout(timeoutID);
|
||||||
|
}
|
||||||
|
|
||||||
|
timeoutID = window.setTimeout(function () {
|
||||||
request = $.ajax({
|
request = $.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "query",
|
url: "query",
|
||||||
@ -54,6 +62,7 @@ $('#search').on('input', function () {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}, timeoutMs);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make the number of document a little bit prettier
|
// Make the number of document a little bit prettier
|
||||||
|
Loading…
Reference in New Issue
Block a user