This is more a question of what happens in my code. It works, but I need to enlighten a little ...
I am using jQuery to create an event listener on a text input element. HTML will look like this:
<input type="text" id="autocomplete" size="50" />
I need to receive events whenever someone enters something into this field, and in order not to flood events, I set up an event listener with a timer so that my event listener code is executed only if the user did not type anything for 125 ms:
jQuery('#autocomplete').keyup(function(e) {
e.preventDefault();
clearTimeout(this.timer);
this.timer = setTimeout(function() {
jQuery.getJSON([URL goes here], function(data) {
}
}, 125);
console.log(this);
});
, , , . , ID , . , this.timer. this . , console.log:
<input type="text" id="autocomplete" size="50" />
ID ? , - . " ", - ?