drpogkqqi536984960 2019-02-14 09:56
浏览 159

JQuery中的Datepicker和DataTable上的结果显示在Laravel应用程序中不起作用

I'm using Laravel 5.4, and start using [Date Range Picker] by Dan Grossman1 to chose two dates, then a request by Ajax will get the response later with the results to show back in Yajra DataTable.

The Ajax side working well, I already test it and it is working well. but now my problem start after using Datepicker, where the results shown for the first time right and looks working, but when I pick and chose date then click submit on search button, It keep on same data before, which means Ajax not working with new changes, May I know the reason and how to fix it to make the data sent by AJAX request working well.

HTML Code:

<div id="reportrange"
    style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
    <i class="fa fa-calendar"></i>&nbsp;
    <span></span> <i class="fa fa-caret-down"></i>
</div>
<input type="submit" id="search_leads" name="search" value="search" class="btn btn-primary">

Jquery Code:

$(document).ready(function () {


    $(function () {

        var start = moment().subtract(15, 'days');
        var end = moment();

        function cb(start, end) {
            $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));

        }

        $('#reportrange').daterangepicker({
            startDate: start,
            endDate: end,
            ranges: {
                'Today': [moment(), moment()],
                'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                'Last 7 Days': [moment().subtract(6, 'days'), moment()],
                'Last 30 Days': [moment().subtract(29, 'days'), moment()],
                'This Month': [moment().startOf('month'), moment().endOf('month')],
                'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
            }
        }, cb);

        cb(start, end);
        // alert(start.format('YYYY-M-DD hh:mm:ss') + end.format('YYYY-M-DD hh:mm:ss'));


        var allUsersTable = $('.allleads').DataTable({
            processing: true,
            serverSide: true,
            // "bSort": false,
            ajax: {
                url: "{{ url('lead/GetAllLeads') }}",
                data: function (d) {
                    d.level = $('#levelFilter').val(),
                        d.start_time = start.format('YYYY-M-DD hh:mm:ss'),
                        d.end_time = end.format('YYYY-M-DD hh:mm:ss')
                }
            },
            {{--"ajax": "{{ url('lead/GetAllLeads') }}",--}}
            // "data": level = $('#levelFilter').val(),
            columns: [
                {"data": "lead", "name": "lead"},
                {"data": "email", "name": "email"},
            dom: 'Bfrtip',
            buttons: [
                'copy', 'csv', 'excel', 'pdf', 'print'
            ]
        });


        $("#search_leads").click(function () {
            allUsersTable.draw();
        });


    });

`

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥20 matlab yalmip kkt 双层优化问题
    • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
    • ¥88 实在没有想法,需要个思路
    • ¥15 MATLAB报错输入参数太多
    • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
    • ¥15 有赏,i卡绘世画不出
    • ¥15 如何用stata画出文献中常见的安慰剂检验图
    • ¥15 c语言链表结构体数据插入
    • ¥40 使用MATLAB解答线性代数问题