So, right now I have an input form as a "search bar." On key up, it fetches some html from a page and displays it in a div. What I want to do is only fetch this html data IF more than 1 second has passed AFTER the key up. Otherwise, if another key was pressed before this 1 second, the timer will reset and start on the next key up.
So, like this
onkeyup -> start timer
once one second passes -> call getList function
onkeyup before one second passes, restart timer
Any ideas? Thanks.
$('#searchbar')
.bind('keyup', function(e){
document.getElementById("result").innerHTML = "";
getList();
});
function getList() {
$.get("myaspscript", function(data, status) {
$(result).html( data );
});
}