N
N
NikitaPythonGO2018-03-05 21:14:49
JavaScript
NikitaPythonGO, 2018-03-05 21:14:49

How to render website data in a table using JS?

There is a function that takes a dictionary with fields ['Name'] and ['Price']. How to draw a conclusion so that the name is displayed in the table and next to the price, while when new data arrives, the old ones are updated with new ones, and not just added (this has already been done)

socket.on('my_pos', function(msg) {
                $("#log1").html('');
                var fir = msg.data['Name']
                var sec = msg.data['Price']
                fir.forEach(item => $("#log1").append(`<tr><td>${item}</td></tr>`));
                sec.forEach(item => $("#log1").append(`<tr><td>${item}</td></tr>`));
            });

<table id="log1" border="1" width="100%" cellpadding="15"></table>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-03-05
@demon416nds

rewrite the table as a
whole

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question