How to handle 400 status in Ajax [duplicate]

This function will load the JS scripts:

function test_ajax_load_scripts() {
// load our jquery file that sends the $.post request
wp_enqueue_script( "ajax-test", plugin_dir_url( __FILE__ ) . '/ajax-test.js', array( 'jquery' ) );

// make the ajaxurl var available to the above script
wp_localize_script( 'ajax-test', 'the_ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );  }
add_action('wp_print_scripts', 'test_ajax_load_scripts');