Answer the question
In order to leave comments, you need to log in
How to send a search request after a certain time after input?
You need to do a search. I thought to do it on the oninput event, but then too many requests would go to the server. And the onchange event is fired when the focus changes. How to make the request be sent after some time after the user has stopped typing, let's say after 2 seconds?
Answer the question
In order to leave comments, you need to log in
var timer; // создаем переменную для таймера
$('input').keyup(function(){
cleatInterval(timer); //если человек написал символ, то удаляем таймер, который создаем далее.
timer=setTimeout(function(){ //создаем таймер, который сработает, если в течение двух секунд его не удалили
//ajax-запрос
},2000);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question