This function works (suspends the call) but the search value is not updated. If I enter "hello" the value passed to the function ($(this).val()) is "he". Is there a way to update it the key value so that it passes the whole search?.
$('#search').keyup(function () {
if ($(this).val().length > 1) {
var searchthis = $(this).val()
if (srun === 1 && stimer) {
if (stimer) {
window.clearTimeout(stimer)
}
} else {
srun = 1
var stimer = setTimeout(loadsearch(searchthis), 2000)
}
}
})
loadsearch() sets the var srun to 0;