javascript - AJAX 响应后数据表未更新
问题描述
我正在执行 ajax 调用,但数据表在响应后没有更新。我已经尝试了几个功能。请注意,我使用 jQuery 版本 2.2.4
$.ajax({
type: 'POST',
url: URL,
data: parsed,
dataType: "json",
beforeSend: function() {}
}).done(function(data) {
let Content = '';
$("#order-table-data").html(Content);
$("#datatable").trigger("update");
$("#datatable").ajax.reload(); //Cannot read property 'reload' of undefined
})
html:
<table id="datatable" class="table table-striped table-bordered">
<thead>
<tr>
<th>Product</th>
<th>Stock</th>
<th>Price</th>
<th>Quantity</th>
<th>Order</th>
</tr>
</thead>
<tbody id="order-table-data"></tbody>
</table>
解决方案
这可能会帮助你
$("#datatable").DataTable().ajax.reload(null, false );
或者
$("#datatable").ajax.reload(null, false);
推荐阅读
- python - 在 RaspBerry Pi 上安装 Anaconda 时出现问题
- javascript - 使用 Ionic 检查 Firebase 中是否存在数据
- javascript - 检测没有事件的浏览器窗口调整大小
- sql - 在 SQL 中计算当前行和下一个可用日期值之间的差异
- java - 将嵌套地图转换为嵌套列表
- android - Xml - 带线条的背景
- spring-boot - 使用 JDK 14 的 spring boot 应用程序无法启动。也没有错误
- floating-point - 可以在 Julia 中使用 Float64 表示的最大正整数
- caching - 云端缓存策略中查询参数的格式是什么
- postgresql - 如何使用 SQLAlchemy / Python 推迟缓慢的数据库操作