Move your add action call to ‘wp_ajax_fhw_do_ajax_request’ to outside the enqueue scripts callback. admin-ajax.php requests do not try to enqueue scripts. Your add action call can execute on plugin load, it does not need to be in a callback.
As I understand, I should use this code like so
add_action( 'wp_enqueue_scripts', 'fhw_register_script' );
add_action( 'wp_ajax_fhw_do_ajax_request', 'fhw_do_ajax_request' );
function fhw_register_script() {
wp_register_script( 'fhw_formular', plugins_url( '/js/formular.js', __FILE__ ), array( 'jquery' ) );
wp_enqueue_script( 'fhw_formular' );
wp_localize_script( 'fhw_formular', 'ajax_object',
array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'we_value' => 1234 ) );
wp_enqueue_script( 'fhw_formular' );
}
The 400 Bad Request error persists.