If you visit Google.com and type in a letter in the search bar, it seemingly transports you to another page instantly. You can type as fast as possible during this time and Google doesn't lose a single character.
I've tried emulating this with keyup() events and setinterval() but I still end up losing a character or two by the time it loads the page.
$(document).ready(function(){
var timer;$("input#q").keyup(
function(e){
var str = $("input#q").val();
if(str.length > 1){
clearInterval(timer);timer = setTimeout(
function(){var url = "/search/?q="+encodeURI($("input#q").val());
location.href = url;}, 210);
}
});
This is the code I'm currently using, it works but can lose a keypress/keyup when it transfers you to the next page.
Does anyone know how Google does it or have any suggestions?
Thanks