A
A
Artem2016-12-17 10:27:32
JavaScript
Artem, 2016-12-17 10:27:32

How to parse JSON and build a table from it?

There is a task to build a table according to data from json, and insert a tree into the DOM.
Json is an array of objects of the form:

[
{"ip":"::1","time":"2016-12-17 12:12:59","request":"GET /insert HTTP/1.1","name":"access.log"},
{"ip":"::1","time":"2016-12-17 12:12:59","request":"GET /insert HTTP/1.1","name":"access.log"},
{"ip":"::1","time":"2016-12-17 12:12:59","request":"GET /insert HTTP/1.1","name":"access.log"},
{"ip":"::1","time":"2016-12-17 12:12:59","request":"GET /insert HTTP/1.1","name":"access.log"}
]


Stupid, I can not understand how I can access the properties of the object.
Those. in general, the algorithm is as follows:
1) Create a table
2) Create a DOM element table row
3) Get an object
4) parse
5) shove data from the object into a row
6) add a row to the table
7) repeat steps 2-6 as long as there are objects in json .
8) Add table to DOM

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
amorphine, 2016-12-17
@amorphine

A web developer must be able to refrain from building bicycles in the first place.
Here is the source . Remove ajax-component and use it. There are also a bunch of ready-made libraries.
If this is an educational task, then I advise you to start studying yesterday, and not by the end of the semester.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question