JSFiddle - React, Tailwind, and code Playground
by Ingush Abrek
HTML
<input type="text" placeholder="Введите текст...">
<span></span>
JavaScript
$('input').on('keyup', function(){
var $this = $(this);
var delay = 500;
clearTimeout($this.data('timer'));
$('span').text('Загрузка...');
$this.data('timer', setTimeout(function(){
$this.removeData('timer');
$.post('?search', { q: $this.val() }, function(){
$('span').text('Готово!');
});
}, delay));
});