I am trying to display search results when typing starts in input
element. when the user click out side of the input element then the results should dismiss(I am not including the searh results itself yet). I am trying to stop the propagation in keyup
to html
element. However, the propagation continues upward. and the results are cleared before they are displayed as typed in the input. should I include the keypress
too?
$('#inputsearch').keyup(function(event){
var searchterms=$('#inputsearch').val();
console.log(searchterms);
$.ajax({
type:'POST',
data:{'searchterms': searchterms},
url:'displaysearch.php',
success: function(response){
$("#searchingresults").empty().html(response);
}
});
event.stopPropagation();
});
$('html').click(function(){ $('#searchingresults').empty().hide();});