git_bsmd/AIS/bsmd.AIS2Service/update.js

41 lines
1.1 KiB
JavaScript

function update() {
fetch('http://localhost:9050/api/ais')
.then(function (response) {
return response.json();
})
.then(function (data) {
updateData(data);
})
.catch(function (err) {
console.log('error: ' + err);
});
function updateData(data) {
var table = document.getElementById("aisTable");
const table = document.getElementById('Table');
let numItems = 1;
numItems++;
const row = document.createElement('tr');
row.innerHTML = `
<td>
<input type="text" id="itemDescription${numItems}" placeholder="Item" />
</td>
<td>
<input type="text" id="itemValue${numItems}" placeholder="Value" />
</td>`;
// You could also do the same for the cells and inputs
table.appendChild(row);
for (var i = 0; i < data.length; i++) {
var div = document.createElement("div");
div.innerHTML = 'Name: ' + data[i].Name;
mainContainer.appendChild(div);
}
}
}
function startup() {
setInterval(function () { update(); }, 10000);
}