Call product search from custom hook
Question
I am trying to make search request from my custom form. For this I have an AJAX call on form submit:
jQuery("#header-search").on('submit', function () {
jQuery.ajax({
url: my_ajax_object.ajax_url,
data: jQuery(this).serialize()
})
.then(function (res) {
console.log(res)
})
return false
})
In my functions.php I have:
function custom_search () {
//WHAT SHOULD I CALL HERE
}
add_action( 'wp_ajax_nopriv_custom_search', 'custom_search' );
add_action( 'wp_ajax_custom_search', 'custom_search' );
I am not sure if this should be made as AJAX but I don’t really understand what action should I put on the search form in the HTML. Everything seems like a mess for me. Can you assist me this? Appreciating every suggestion.
0
2 months
0 Answers
17 views
0
Leave an answer
You must login or register to add a new answer .