search

Home  >  Q&A  >  body text

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

   // 点击查询按钮
        $("#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('获取到数据之后的操作');
                }
            });
        })
    });
    
    
    
    
    

PHPzPHPz2815 days ago678

reply all(2)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-19 10:48:57

    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

    reply
    0
  • 迷茫

    迷茫2017-05-19 10:48:57

    reply
    0
  • Cancelreply