<script type="text/javascript" src="/public/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function(){
	var search = function(term){
		$.get('/search/' + term, {
			data: {}
		}).success(function(response){
			$("#results").html(response);
		});
	};
	$(".main-search").focus().on("keyup blur", function(e){search($(this).val())});
});
</script>
<script type="text/javascript" src="/public/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function(){
	var search = function(term){
		$.get('/search/' + term, {
			data: {}
		}).success(function(response){
			$("#results").html(response);
		});
	};
	var typeTimeout = null;
	$(".main-search").focus().on("keyup blur", function(e){
		var val = $(this).val();
		if (typeTimeout){
			clearTimeout(typeTimeout);
		}
		typeTimeout = setTimeout(function(){
			return (function(v){
				search(v);
			}(val));
		}, 500);
	});
	$(".header .title").on('click', function(){
		$('.main-search').focus();
		return false;
	});
});
</script>
Add delay to calling ajax when typing
Add delay to calling ajax when typing
