Hi there,
Firstly, I am new here, thank you for your time reading this today
We have a customer management system for our repair store.
We have an issue whereby our new host doesn’t like the constant searches that come from our “live search” box that is on the customer profile
Here is the coding of which I believe is responsible for this live search
>
$(document).ready(function(){
> $(“input#autoinvsearchbox”).keyup(function(){
> if(this.value.length<3) {
> $(“div#autoinvsearch”).slideUp(200,function(){
> return false;
> });
> }else{
> var encodedinv = encodeURIComponent(this.value);
> $(‘div#autoinvsearch’).load(‘autosearch.php?func=inv&search=’+encodedinv).slideDown(200);
> }
> });
> });
Please could you help me change this so that it only works once the user stops typing?
I have managed it with another part of the coding for the customer name section using the following adaption
From this
>
>
$(this).change(update).keyup(update).keydown(update);
>
> update.apply(this);
>
> });
>
> return this;
To this :
>
>
function debounce(callback, wait) {
> let timeout;
> return (…args) => {
> clearTimeout(timeout);
> timeout = setTimeout(function () { callback.apply(this, args); }, wait);
> };
> }
>
window.addEventListener(‘keyup’, debounce( () => {
> update.apply(this);
> // code you would like to run 1000ms after the keyup event has stopped firing
> // further keyup events reset the timer, as expected
> }, 1000))
>
>
>
> });
>
> return this;
I appreciate any suggestions or help received, thank you again- for your time