如果我发送一个ID,删除不可能

I send an id with Ajax. Only he does not remove the selected id from the database?

The Ajax:

function delete_category(id) {
$('#category'+id).html('<div class="preloader-retina"></div>');
$.ajax({
    type: "POST",
    url: "categories.php",
    data: "id="+id, 
    cache: false,
    success: function() {
       $('#category'+id).fadeOut(500, function() { $('#category'+id).remove(); });      
    },
    error: function(){      
       $('#category'+id).html('Sorry, Er is een fout op getreden tijdens het verwerken van de gegevens. ');
    }
});
}

The Submit:

//Check if the form has been submitted
if (isset($_POST['id'])) {

foreach ($_POST['id'] as $value) {

    $where = array(
        'category_id' => $value
    );

    $db->where($where);
    $db->delete(config_item('cart', 'table_categories'));

    foreach ($db->query("SELECT category_id FROM " . config_item('cart', 'table_categories') . " WHERE parent_id = '" . $value . "'") as $row) {

        $where = array(
            'category_id' => $row['category_id']
        );

        $db->where($where);
        $db->delete(config_item('cart', 'table_categories'));

    }

}

header("Location: categories.php");
}

What am I doing wrong now?

The ID will be received by the Ajax but Id will not be removed

Thanks for your answers!

You are not passing an array to php, yet you try to loop through $_POST['id']. To send an array you would need to change the following line:

data: "id="+id, 

to

data: { 
    id : [id] // send an array of id's under the key 'id'
}