You are forgetting to cancel the default action, which is to submit the page:
$('#search-btn').on('click',function(){
var search_term = $('#search-val').val();
$.get( "/?search_term="+search_term);
return false;
});
Without the return false
the browser will happily also submit the form itself, which in this case means it'll use GET
on the same URL as the page (there is no action
attribute). This in turn cancels any pending AJAX requests as well.
Of course, your $.get()
call still doesn't do anything on the browser-side, but at least by cancelling the default form action, you get to see a server-side effect.