// Original code from Nathan Claire's blog // http://nathanleclaire.com/blog/2013/11/16/the-javascript-question-i-bombed-in-an-interview-with-a-y-combinator-startup/ $(document).ready(function() { $('input').keypress(function() { if (this.timeoutId) window.clearTimeout(this.timeoutId); this.timeoutId = window.setTimeout(function () { $.ajax({ // do some stuff }); }, 200); }); });