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 to require those files outside of the admin_menu hook.

tech