Using namespaced functions within ajax handlers
-
So I am trying to use a namespaced function as the value for my “action” key in my ajax handler, but I’m not sure how to pull this off.
First, here are the relevant links from my php:
namespace Roots\Sage\Extras; use Roots\Sage\Setup; function doctor_search() { include( locate_template( 'shortcodes/templates/dr-search-results.php') ); } add_action( 'wp_ajax_sbh_doctor_search', __NAMESPACE__ . '\\doctor_search' ); add_action( 'wp_ajax_nopriv_sbh_doctor_search', __NAMESPACE__ . '\\doctor_search' );
Here is the javascript:
// The Data var data = { action : 'sbh_doctor_search', last_name : last_name, first_letter : first_letter, specialty : specialty, languages: languages }
As you can see I am using the functionality included within Sage / Roots. I might repost this over there, but was hoping somebody might be able to help me out here. Thanks.
- The topic ‘Using namespaced functions within ajax handlers’ is closed to new replies.