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

How to submit a button automatically after every scheduled hours?

You were on the right track with the second try. Put this is functions.php, or wherever: if (!wp_next_scheduled(‘fetch_webcategories_hook’)) { wp_schedule_event( time(), ‘hourly’, ‘fetch_webcategories_hook’ ); } add_action ( ‘fetch_webcategories_hook’, ‘fetch_webcategories’ ); It’s not quite a real hourly schedule because somebody has to visit the site to trigger it, so if you have VERY low traffic it … Read more