javascript - datatables How to write a successful callback function to obtain time in the background and search the time period to obtain data and re-render? ? ? ? Ask God for answers
PHPz
PHPz 2017-05-19 10:46:57
0
2
645
   // 点击查询按钮
        $("#carBtn").on('click', function () {
            $.ajax({
                url: '',
                type: 'POST',
                // 开始时间和结束时间传给你
                data: {minDate: $(".startCreateTime").val(), maxDate: $(".endCreateTime").val()},
                async: false,
                cache: false,
                contentType: false,
                 processData: false,
                success: function (data) {
                    alert('获取到数据之后的操作');
                }
            });
        })
    });
    
    
    
    
    

PHPz
PHPz

学习是最好的投资!

reply all(2)
phpcn_u1582

It shouldn’t be written like this. Datatables has its own method to refresh. Generally speaking, there is no need to write ajax manually

$('#_list').DataTable({
    dom: "Brtip",
    serverSide: true,
    processing: true,
    order: [[3, 'desc']],
    ajax: {
        url: URL_PREFIX + schema.API.UM_LIST.url,
        type: 'get',
        data: function (data) {
            // data['conditions'] = $('#_query_form').serializeArray();
            data['keyword'] = self.keyword
            data['workGroupID'] = self.workGroupID
        },
        error: function(resp) {
            if (resp.status == 403) {
                toastr.info('没有权限访问')
                self.loadUser()
            }
        },
        beforeSend: oauthHeaders
    }
)

When the data changes (when the button is clicked), you should set the value into data 方法里,然后调用$('#_list').DataTable().ajax.reload()It will be refreshed

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!