如何使用Ajax响应数据使用BootstrapTable

时间:2019-02-11 09:24:46

标签: bootstrap-table

我正在自定义Ajax中使用BootstrapTable 4.0。他们调用已定义的Ajax函数的页面加载时间。那么我将调用该ajax函数显示错误:

Uncaught TypeError: params.success is not a function

在页面加载时,它们没有显示错误,但是在那个时候正在调用自定义ajax函数。

<table
 id="tblSch"
 data-toggle="table" 
 data-height="460" 
 data-ajax="ajaxRequest" 
 data-search="true" 
 data-side-pagination="server" 
 data-pagination="true" 
 data-show-export="true" 
 data-detail-formatter="detailFormatter" 
 data-show-columns="true" 
 data-show-pagination-switch="false" 
 data-pagination="true" data-id-field="id" 
 data-page-size= 10 
 data-show-footer="false" 
 data-response-handler="responseHandler">
 <thead>
   <tr>
     <th data-field="id">id</th>
     <th data-field="name">Name</th>
     <th data-field="price">Price</th>
   </tr>
  </thead>
</table>

function ajaxRequest(params){
    console.log(params);
    var res =JSON.parse(params).rows;
    setTimeout(function () {
        params.success({
        total: res.total,
        rows: [{
          'id': 1,
          'clientName': 'Item 0',
          'activity': '$0'
        }]
      })
    }, 1000)
}

我的自定义Ajax代码

$.ajax({
    type: "POST",
    url: root_url+"appointments/gets",
    data: {
        clientName : clientName,
        providerName : providerName,
        statusName : statusName,
        locationName : locationName,
        fromDate : fromDate,
        toDate : toDate,
    },
    success: function(result) {
        tblSch(result);
    }
});

0 个答案:

没有答案
相关问题