This is my first question, any suggestions on further questions will be appreciated.
When using the following code to update a table I don't see any updates, however when moving the TableList = {}
into the success function, the table will update like intended.
Can someone give me an explanation to why I need to move the emptying of the object into the success block?
Answers I've read don't seem to help me understand any better.
function GetTableData() {
TableList = {};
$.ajax({
url: "http://localhost:3000/info/",
success: function (result) {
//Moiving 'TableList = {}' here works fine
for (var i = 0; i < result.length; i++) {
TableList[i] = result[i];
}
}
});
}
function UpdateTable() {
GetTableData()
//Update table cells
setTimeout(function () {
UpdateTable();
}, 1000);
}