I have this classes
class mainclass {
public function __construct() {
add_action('wp_ajax_ajax_func', array( $this, 'ajax_func' ) );
}
public function ajax_func() {
}
}
class child1 extends mainclass {
public function __construct() {
}
public function ajax_func() {
echo "Test child1";
}
}
class child2 extends mainclass {
public function __construct() {
}
public function ajax_func() {
echo "Test child2";
}
}
every class of the child classes have ajax function ajax_func()
and the jQuery code
jQuery.ajax({
url: 'admin-ajax.php',
data: {action : 'ajax_func'},
success: function(data){
console.log(data);
}
});
the console.log
return Test child1Test child20
i want to call one of them not all functions in classes
is there any way to call it like this data: {action : 'child1.ajax_func'}
?