意外的令牌:,Ajax成功消息Laravel

时间:2017-02-06 02:43:41

标签: php jquery ajax laravel datatables

我正在尝试Ajax成功方法中的Ajax成功消息,但是我得到了意外的令牌(我的控制台上的错误使用了inspect元素浏览器。

到目前为止,这是我的Ajax代码:

$(document).ready(function() {
        var rawDORecordsDataTable = $('#raw_do_record_table').DataTable(
        {
            dom: 'Blrtip',
            orderCellsTop: true,
            responsive: true,
            processing: true,
            serverSide: true,
            iDisplayLength: 50,
            ajax: {
                url:  '{{ route('raw_do_record.list') }}',
                data: function(data) {
                    data._token = '{{ csrf_token() }}';
                    data.do_date = $('#search_date').val();
                    data.do_status = 0;
                },
                type: 'POST',
            },
            columns: [
                { data: 'do_no', name: 'do_no' },
                { data: 'do_status', name: 'do_status' },
                { data: 'customer', name: 'customer' },
                { data: 'store_isn', name: 'store_isn' },
                { data: 'warehouse_status', name: 'warehouse_status' },
                { data: 'do_date', name: 'do_date' },
                { data: 'delivery_status', name: 'delivery_status' },
                { data: 'action', name: 'action', orderable: false, searchable: false },
            ] ,
            searchCols: [
                null , 
                { "search" : 0} ,
            ],
            buttons: [
                @if(Gate::allows('views',[[Department::LOGISTICS]]))
                { text: 'Generate All',
                    action: function ( e, dt, node, config ) {
                        $('#generate_all_modal').modal('show')
                    } 
                },
                @endif
                { text: '<i class="fa fa-refresh"></i> Refresh DO',
                    action: function ( e, dt, node, config ) {
                        $('#refresh_do_modal').modal('show')
                    } 
                }
            ],

        })
        .on('click', 'a.stop', function(e) {
            $.ajax({
                url: '{{ route('raw_do_record.list') }}',
                type: 'POST',
                data: { 
                    '_token' : '{{csrf_token() }}',
                },
                success: function(data) {
                    alert("asd");
                },
                error: function(data) {
                    alert("asdasd");
                }
                });
            });

这是模态html:

<div class="modal fade bs-modal-sm" id="stop_modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
    <div class="modal-content">
    {{ Form::open([
        'method' => 'POST',
        'id' => 'stop-form'
    ]) }}
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h4 class="modal-title">Stop Confirmation</h4>
        </div>
        <div class="modal-body">
            <div class="form-group">
                <label>Are you sure want to stop the process?<br>This DO no longer useable</label>
            </div>
        </div>
        <div class="modal-footer">
            <button class="btn sbold btn-danger" type="submit"> 
                </i> Yes
            </button>
            <button type="button" class="btn sbold blue" data-dismiss="modal">No</button>
        </div>
    {{ Form::close() }}
    </div>
</div>

任何想法?

0 个答案:

没有答案