Using AJAX to return search form results
There are two issues in your code You need to add script in wp_enqueue_scripts hooks like this – add_action(‘wp_enqueue_scripts’, ‘my_custom_js_script’); function my_custom_js_script() { wp_register_script( ‘ajax-productSearch’, get_template_directory_uri() .’/js/ajax-product-search.js’, array( ‘jquery’) ); wp_enqueue_script( ‘ajax-productSearch’ ); wp_localize_script( ‘ajax-productSearch’,’the_ajax_productSearch’, array(‘ajaxurl_productSearch’ => admin_url(‘admin-ajax.php’))); } The second issue is that, you need to add action argument in your jQuery.ajax data. If … Read more