Yuki Neko
Yuki Neko

Reputation: 1

pass the ajax data processed to route Laravel 6.x

I want pass the ajax data processed to route but i don't know do it. Here this my code ajax:

$.ajax({
                url: "{{ route('order.by.status') }}",
                method: "POST",
                data: {
                    _token: _token,
                    start: start,
                    end: end,
                    sell_buy: sell_buy,
                    status: status,
                },
                success: function (data) {
                    $('#tbody_data').html('');
                    $.each(data.orders, function (key, value) {
                        $('#tbody_data').append(    `<tr>
                            <td>${ key +1 }</td>
                            <td style="color:#007a6e">
                                <b>${ value.code_deal }</b><br>
                                <a style="font-size: 12px;" href="{{ route('order.by.status', value.id) }}">Detail</a>
                                // I want pass id to href of route this but Fail
                            </td>
                            <td>
                                <b>${ value.name }</b>
                                <br> ${ value.phone }
                            </td>
                            <td>${ value.content }</td>
                        </tr>`)
                        });
                }
            });

This is route:

Route::post('order_by_status','Backend\StatusController@getOrderByStatus')->name('order.by.status');

Please help me! Thanks!!!

Upvotes: 0

Views: 35

Answers (1)

Guljahan Ilmedova
Guljahan Ilmedova

Reputation: 72

$.ajax({
            headers: {
              'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            type: "post",
            url: "/order_by_status",

i use for pass the ajax data processed to route-> headers(try it)

Upvotes: 0

Related Questions