wordpress plugin ajax 400 Bad Request

I am developing a wordpress-plugin to add pages as favorites. Therefore i wrote a function to delete favorites from the database. The code worked perfectly in the past. I dont know what i might have changed to make it stop working. When i try to delete a favorite the server throws a 400 Bad request exception. The same problem occurres with the ajax-call to load the favorites… I would be grateful if someone could help me with this problem.

script.js:

function deleteFavorite(page_id){
    console.log("test");
    jQuery(document).ready(function($) {
        var data = {
            'action': 'fav_delete',
            'page_id': page_id
        };
        jQuery.post(fav_ajax_object.ajax_url, data, function(response) {
            if(response!=0)
                alert(response);
        });
    });
}

delete.php:

<?php
add_action( 'wp_ajax_fav_delete', 'fav_delete' );
add_action( 'wp_ajax_nopriv_fav_delete', 'fav_delete' );


function fav_delete() {

    if(isset($_POST['page_id'])){
        $eppn = get_eppn();
        $page_id= $_POST['page_id'];

        global $wpdb;
        $table = 'wp_favoriten';

        $where = array('page_id' => $page_id, 'eppn' => $eppn);
        $format = array('%d','%s'); 
        $wpdb->delete($table,$where,$format); 

        echo $wpdb->print_error();
    }
        
}
?>

main.php:


include( plugin_dir_path( __FILE__ ) . 'include/delete.php');

function favPlugin_enqueue_scripts() {
    wp_enqueue_script( 'fav_script', plugins_url( 'js/script.js', __FILE__ ), array('jquery'));
    wp_localize_script( 'fav_script', 'fav_ajax_object',
            array( 'ajax_url' => admin_url( 'admin-ajax.php' )));

}

It’s the first time i’m using ajax so i’m hoping it’s an easy to fix error that i am just not smart enough to identify on my own 🙂
Also please excuse my bad english, since it’s not my native language