don’t call ajax if not plugin page

You can check for WordPress’s DOING_AJAX constant: if ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) { return; } …or use the related wp_doing_ajax() function: if ( wp_doing_ajax() ) { return; } However, I’d also double-check to make sure that App\Bootstrap has a method named process_moviewp_like as well, because that error doesn’t look like something that … Read more

Ajax filter button display all posts

Going by what @JacobPeattie said, that they are still set but empty you need to change the conditional login to check for empty. In our previous discussion I wrote this conditions if ((isset($_POST[‘categoryfilter1’]) && !empty($_POST[‘categoryfilter1’])) && (isset($_POST[‘categoryfilter2’]) && !empty($_POST[‘categoryfilter2’]))) { // both properties are set and have value (not empty) } elseif ((isset($_POST[‘categoryfilter1’]) && !empty($_POST[‘categoryfilter1’])) … Read more

Ajax Call 400 Bad Request error with POST request but not with GET request

Well this is very probably going to help someone else sometime so here it goes: Not setting the request to application/x-www-form-urlencoded makes the POST body behave like a string. So PHP does not recognize $_POST variables. To make that happen we need: xhttp.setRequestHeader(‘Content-type’, ‘application/x-www-form-urlencoded’); So the whole thing goes like: xhttp.open(“POST”, ajaxurl, true); xhttp.setRequestHeader(‘Content-type’, ‘application/x-www-form-urlencoded’); … Read more

Short code template + ajax

As Tom J Nowell noted in the comments, your setup is bit wonky, which is why it won’t work. You need to add the ajax actions and register the shortcode earlier – i.e in a custom plugin or in the theme functions.php. This is related to how WordPress handles requests and in which order it … Read more

403 error When i send ajax request on WordPress website

Short answer — how can you solve the problem: When you call check_ajax_referer(), use secure_nonce_name as the first parameter, i.e. check_ajax_referer( ‘secure_nonce_name’, ‘security’ ). A Longer Answer The first parameter (which is the nonce action) for check_ajax_referer() needs to match the first parameter for wp_create_nonce(), but in your code, they are secure-nonce-name and secure_nonce_name respectively, … Read more

WP AJAX post filter > do something with empty value

Unfortunately, the answers given did not work. I was only looking at the jQuery portion, but the issue was in the functions filter, which I did not include in my original post. However, you did push me in the direction I needed, so thank you for that! The problem was, I was always getting a … Read more