Tuesday, 21 December 2021

Prevent to excute second time ajax

 




 var timeout;
        jQuery("body").delegate('input[type = text]', 'keypress', function() {
            if (timeout) {
                clearTimeout(timeout);
                timeout = null;
            }

            timeout = setTimeout(myFunction, 2000);
        });

        function myFunction() {
            console.log('myFunction'); // Add your ajax call here
        }




No comments:

Post a Comment