2 Using theme functions file, not site-specific plugin. Updated to indicate.
source | link

And my PHP from my site-specific plugintheme's functions.php file:

And my PHP from my site-specific plugin:

And from my theme's functions.php file:

1
source | link

Using AJAX to return search form results

I'm trying to take user input from a search form, build a query based on user input, and then return relevant posts using AJAX.

Right now, the form builds the select dropdowns properly. The form content disappears on submission, the loading animation appears, and then the results appear. The problem I'm having is the actual result that is returned - no matter what I do (even a simple echo: 'Success'; isn't working), I get a 0 as my return.

Form code:

<form class="form-horizontal" id="product_search_form" name="product_search_form" method="post">
  <div id="product_search_form_content">
    <div class="form-group">
        <label for="inputCarrierSelect" class="col-sm-2 control-label">Carrier</label>
        <div class="col-sm-10">
            <?php sms_populate_carrier_dropdown(); ?>
        </div>
    </div>
    <div class="form-group">
        <label for="inputStateSelect" class="col-sm-2 control-label">State</label>
        <div class="col-sm-10">
            <?php sms_populate_state_dropdown(); ?>
        </div>
        <input type="hidden" name="prdlnSelect" value="<?php echo $pl_slug; ?>" />
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <input class="btn btn-primary" id="submit_button" onclick="product_search();" type="button" value="Search" />
        </div>
    </div>
  </div>
</form>

jQuery:

function product_search(){
  jQuery.ajax({
    data: jQuery('#product_search_form').serialize(),
    type: jQuery('#product_search_form').attr('method'),
    url:  the_ajax_productSearch.ajaxurl_productSearch,
    beforeSend: function(){
      jQuery('#product_search_form_content').remove();
      jQuery('#product_search_form').append('<div class="alert alert-success" role="alert" align="center"><span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> Loading...</div>');
    },

    success: function(response) { // on success..
      jQuery('#product_search_form').html(response);
    },
  });
  return false; // cancel original event to prevent form submitting
}

And my PHP from my site-specific plugin:

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')));

add_action( 'wp_ajax_productSearch', 'ajax_action_productSearch' );
add_action( 'wp_ajax_nopriv_productSearch', 'ajax_action_productSearch' );

function ajax_action_productSearch(){
  echo 'Success';
  die();
}

Is there anything glaringly obvious that I'm doing wrong here?