I am building a live search for a website that will return results based on what the user types. I only want the request to be sent when the user has finished typing.
Maybe your users cannot type fast enough. Set the wait
parameter of the _.debounce
function to be longer than the 100ms in your 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 than 100