I just want to achieve that. if user is searching keyword example "stackoverflow" i just want send a ajax call after that . Not every time he press any key. Thus i can save lot of ajax call every time hw press a key .
Im trying to check that if user didnt press any again for two second after he press any key then i am sending ajax call. but i don't know what to use interval or set time out please help and hope you can understand what i trying to explain . Thanks
here is my little code.
$(document).ready(function(){
var counter = 0;
$("#input").keyup(function(){
var myInterval = setInterval(function () {
++counter;
}, 1000);
if(myInterval > 2)
{
alert('ajax call going');
clearInterval(myInterval);
}
else
{
alert('doing nothing');
}
})
})