wp_ajax function did not call

Finally I’ve found the problem in your code. You’ve forgotten \ on namespace path. class OtherClass{ public function __construct(){ add_action(‘wp_ajax_getItemsByAjax’, array( ‘\Namespace\Common\FooClass’, ‘getItemsByAjax’ ) ); } } I hope it will help you.

Admin-ajax.php 400 error

You have two problems in PHP you need change this is bad: wp_localize_script( ‘customjquery’, ‘ajaxurl’, admin_url( ‘admin- ajax.php’ ) ); change to: wp_localize_script( ‘customjquery’, ‘my_custom_vars’, [‘ajax_url’ => admin_url(‘admin-ajax.php’)] ); and your javascript need this changes is bad: $.ajax({ type: ‘POST’, // use $_POST method to submit data dataType: “html”, url: ajaxurl, change to: $.ajax({ type: … Read more

Ajax WordPress Login needs to be stayed in current page Url without redirecting

Please try following code it will works for you. Please add this in your functions.php for getting current page URL /*Get Current Url */ function currentUrl( $trim_query_string = false ) { $pageURL = (isset( $_SERVER[‘HTTPS’] ) && $_SERVER[‘HTTPS’] == ‘on’) ? “https://” : “http://”; $pageURL .= $_SERVER[“SERVER_NAME”] . $_SERVER[“REQUEST_URI”]; if( ! $trim_query_string ) { return … Read more

Can’t publish post using ajax

To those who are experiencing the same issue, there are few steps to take to determine the culprit. Create posts manually in the WP Dashboard area (set it to future) .. and manually publish (look for the error in the log). step 1 and trash the post, in the Trash, try reverting that post (this … Read more

WordPress Admin AJAX Serialize

Instead of relying on bespoke/custom serialising, and the ancient admin AJAX, consider using JSON and the REST API, e.g.: add_action( ‘rest_api_init’, function () { register_rest_route( ‘ramkumar/v1’, ‘/test/’, array( ‘methods’ => ‘POST’, ‘callback’ => ‘ramkumar_rest_test’ ) ); } ); function ramkumar_rest_test( $request ) { $reviewer_notes = $request[‘reviewer_notes’]; $result = ….; return $result; // gets sent to … Read more