Я получаю некоторые данные с внутреннего сервера и пытаюсь добавить в таблицу начальной загрузки каждые 5 секунд.Он не может отображаться в таблице, хотя я ясно вижу объект json, исходящий из бэкэнда в моей консоли.Я попытался использовать refresh, load и append, а также первый аргумент функции bootstrapTable, но это не помогло.Я хочу, чтобы новые данные добавлялись к существующим данным, когда они поступают из серверной части в формате json, но таблица отображается как полностью пустая в пользовательском интерфейсе.
Файл Javascript
<code>$(document).ready(function() {
getUpdates();
function getUpdates() {
$.ajax({
type: "GET",
contentType: "application/json",
url: "/getUpdates",
dataType: 'json',
cache: false,
timeout: 600000,
success: function (output) {
// var $table = $('#table');
$('#table1').bootstrapTable('refresh', {
data: output
});
console.log("SUCCESS : ", output); //this display correctly in console
},
error: function (e) {
var json = "<h4>Response:</h4><pre>"
+ e.responseText + "
"; console.log("ОШИБКА:", e + "Текст ответа:" + e.responseText); // $ ("# btn-update"). Prop ("disabled", false);}, завершение: function () {//Запланировать следующий запрос, когда текущий объект завершит setTimeout (getUpdates, 5000); // Интервал установлен в 5 секунд}});};});
html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Updates through messaging</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.14.2/dist/bootstrap-table.min.css">
<link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.3.7/css/bootstrap.min.css"/>
</head>
<body>
<div class="container" style="min-height: 500px">
<div class="starter-template">
<h1>CDC Consumer Example </h1>
<div class="container">
<table id="table1" data-height="450">
<thead>
<tr>
<th data-field="id">Id</th>
<th data-field="oldValue">Old Value</th>
<th data-field="newValue">New Value</th>
<th data-field="tableName">Table Name</th>
<th data-field="columnName">Column Name</th>
<th data-field="timestamp">Timestamp</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
<script type="text/javascript"src="webjars/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript" src="javascript/entry.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.14.2/dist/bootstrap-table.min.js"></script>
</body>
</html>