Make the front-end to throttle the request by 100ms

This commit is contained in:
Kerollmops 2020-08-31 13:34:35 +02:00
parent 4afc4d0751
commit 220ba0785c
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -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