首页 > 解决方案 > 带有 AJAX 的引导表“正在加载,请稍候...”

问题描述

我正在尝试使用带有 ajax 请求的引导表,如下例所示: https ://examples.bootstrap-table.com/#options/table-ajax.html

但是,就像在示例中一样,我的数据没有加载,我只收到一条消息说“正在加载,请稍候......”。我试图通过使用隐藏消息,bootstrapTable('hideLoading');但后来我只得到“没有找到匹配的记录”。

您有什么想法为什么官方网站上的示例不起作用?

查看一些代码:

function ajaxRequest(params) {
  $.ajax({
    type: "GET",
    url: "getAjax.php",
    dataType: "json",
    success: function(data) {
      params.success({
        "rows": data,
        "total": data.length
      })
    },
    error: function(er) {
      params.error(er);
    }
  });
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table data-toggle="table" data-detail-view="true" data-detail-view-icon="false" data-detail-view-by-click="true" data-ajax="ajaxRequest" data-detail-formatter="detailFormatter" data-id-field="id" data-page-list="[10, 25, 50, 100, ALL]" class="table table-bordered table-sm table-hover table-responsive"
  id="rtcapi">

  <thead class="thead-light">
    <tr>
      <th data-field="id">#</th>
      <th data-field="status">Status</th>
      <th data-field="ln_demander">Last name</th>
      <th data-field="fn_demander">First name</th>
    </tr>
  </thead>

我试图在 js 函数中 console.log 一些测试,它似乎没有被 html 调用...

谢谢您的回答 !

标签: javascriptjqueryajaxbootstrap-table

解决方案


是否添加了 Bootstrap 和 table JS?

<script src="https://unpkg.com/bootstrap-table@1.15.5/dist/bootstrap-table.min.js"></script>

推荐阅读