wp-admin/admin-ajax.php 400 Bad request (chrome console)

To simplify your process and prevent redundant conditional checks just stack the two actions on top of each other. wp_ajax_ runs for authenticated users and thus does the conditional check of is_user_logged_in() anyway. wp_ajax_nopriv_ does the same thing, but looks for unauthenticated users. The actions themselves run the conditions anyway, so you needn’t run it … Read more

Ajax call to a function in another module returns a 400 (Bad Request) error

Assuming your apps/save-books.php file contains the save_book_form() function and the wp_ajax_save_book_form hook, the problem is that you’re only including this file inside the admin_menu hook. The admin-ajax.php file does not run the admin_menu hook, so your apps/save-books.php file won’t be loaded for admin AJAX requests, which means that your action is never hooked. You need … Read more

AJAX request blocked by CORS policy

The problem was that the PHP AJAX function was redirecting to another page, which caused these issues. I decided to just generate a link instead of redirecting.

Blocking admin-ajax.php from outside domain

If the point of the file is to allow the website to asynchronously post data why would it even be allowed to be accessed directly, especially from an ip that is not the ip of the site itself? AJAX requests come from the user’s IP address, not the site’s, because an AJAX request is by … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)