Ajax callback not work

The problem is a basic PHP issue, you told WordPress to call a function named get_data_from_form when the wp_ajax_get_data_from_form action happens] add_action(‘wp_ajax_get_data_from_form’, ‘get_data_from_form’ ); But no function with that name exists. Sure you have a class with a function inside it that exists, but that’s not the same. Think of it this way, if there … Read more

How to use wp_send_json() and output the value with ajax?

You can follow below steps: HTMl Code: <button id=”clickMe” data-nonce=”<?php echo esc_attr( wp_create_nonce( ‘my-nonce’ ) ); ?>”>Click Me</button> PHP Code: here you need to use wp_ajax hook. class myFunctions{ public function __construct(){ add_action( ‘wp_ajax_clickme’, [$this, ‘ajax_callback’]); // for logged in user only add_action( ‘wp_ajax_nopriv_clickme’, [$this, ‘ajax_callback’]); // for non logged user only } public function … Read more