0

代码工作正常,但是当我尝试键入任何键进行搜索时,会显示以下错误:

数据表错误

DataTables 警告:table id=my-table - Ajax 错误。有关此错误的更多信息,请参阅http://datatables.net/tn/7

请求错误(网络):

状态码:404 未找到

JS

jQuery('#my-table').dataTable({
        columnDefs: [],
        pageLength: 5,
        lengthMenu: [[5, 8, 15, 20], [5, 8, 15, 20]],
        autoWidth: false,
        processing: true,
        serverSide: true,
        searching: true,
        ordering: true,
        ajax: "{{route('getdatatable')}}",
        columns: [
            {data: 'commande_num', name: 'commande_num'},
            {data: 'id_client', name: 'id_client'},
            {data: 'commande_quantity', name: 'commande_quantity'},
            {data: 'commande_montant', name: 'commande_montant'},
            {data: 'commande_date', name: 'commande_date'},
            {data: 'commande_date_retrait', name: 'commande_date_retrait'},
            {data: 'commande_paid', name: 'commande_paid'}
        ]
    });

HTML(表格)

<table id="my-table" class="table table-bordered table-striped table-vcenter ">
   <thead>
          <tr>
            <th class="text-center" style="width: 10%;">NO°</th>
            <th class="d-none d-sm-table-cell text-center" style="width:10%;">Client</th>
            <th class="d-none d-sm-table-cell text-center">Quantity</th>
            <th class="d-none d-sm-table-cell text-center">Montant Total</th>
            <th class="d-none d-sm-table-cell text-center">Date de Facture</th>
            <th class="d-none d-sm-table-cell text-center">Date de Retrait</th>
            <th class="d-none d-sm-table-cell text-center">Paiments</th>
          </tr>
    </thead></table>

后端(laravel)

public function tableCommandes(){
    //commandes arrays
    $commandes=[];
    for ($i = 0 ;$i<7;$i++){

        $thisDay = DB::table('commandes')
            ->where("commande_date","=",Carbon::now()->startOfWeek()->addDays($i))
            ->whereNotNull('deleted_at')->get();
        foreach ($thisDay as $item){
            array_push($commandes,$item);
        }
    }
    $collection = new Collection($commandes);
    return (new CollectionDataTable($collection))->make();
}

请帮忙!

4

0 回答 0