jQuery(document).ready(function($){
var num=5;
$('.input_search').on('input', function(){
var keyword=$(this).val();
var form=$(this).closest('form');
$.ajax({
type: 'POST',
url: ajaxurl,
data: {
action: 'product_search',
s: keyword,
num: num
},
success: function(response){
form.next('.search_result').html(response).show();
}});
});
$('.input_search').on('keypress', function(e){
if(e.which==13){
e.preventDefault();
var keyword=$(this).val();
var form=$(this).closest('form');
window.location.href=form.attr('action') + '?s=' + encodeURIComponent(keyword) + '&et_pb_searchform_submit=et_search_proccess&et_pb_include_posts=yes&et_pb_include_pages=yes';
}});
$(document).on('submit', '.search_form', function(e){
e.preventDefault();
var keyword=$(this).find('.input_search').val();
window.location.href=$(this).attr('action') + '?s=' + encodeURIComponent(keyword) + '&et_pb_searchform_submit=et_search_proccess&et_pb_include_posts=yes&et_pb_include_pages=yes';
});
});