Jquery ajax search debounce -


i building live search website return results based on user types. want request sent when user has finished typing.

i have tried few implementations using timers , debounce method underscore.js seem getting similar result.

while typing, request delayed until have finished typing. seems fire inputs if queued. example, if type in "bikes" results come like:

b  bi  bik  bikes 

as such, stream of results search.

this current implementation using underscore js

$('#search_term').on('keyup', _.debounce(function (e) {         $.ajax({             type: "get",              url: "quicksearch.php",             data: { search_term:$('#search_term').val()},             success: function(msg){               $('#quick_search_results').html(msg).slidedown();             }     });  }, 100)); 

anyone have ideas?

maybe users cannot type fast enough. set wait parameter of _.debounce function longer 100ms in example: (see specs: _.debounce(function, wait, [immediate]).

$('#search_term').on('keyup', _.debounce(function (e) {    $.ajax({         type: "get",         url: "quicksearch.php",         data: { search_term:$('#search_term').val()},         success: function(msg){$('#quick_search_results').html(msg).slidedown();}    }); }, 300)); // < try 300 rather 100 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -