Access the information of an attribute of a json file
Access the information of an attribute of a json file
I can't show the time attribute that appears inside the json_log attribute
$.ajax(settings).done(function (response) {
response.data.forEach(a => {
console.log(JSON.parse(a.json_log).tiempo)
$("#total").DataTable().rows.add(JSON.parse(a.json_log)).draw();
});
});
}
var table = $("#total").DataTable({
columns:[
{
title: "Fecha",
data: "tiempo"
}
]
});
In the inspector of the browser it shows well but I don't know how to show it in the column, I already tried writing data: "data", data: "a", data: "time"
This discussion has been closed.
Replies
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Ok
Is private i cant run the code. If you can orient yourself with the photo better
Take an example (2 or 3 rows) of your JSON object, by copying it from the network inspector, and create a Javascript variable. Use that for a test case. See this example to learn how to use Javascript sourced data.
Kevin
ok
Please start a test case so we can help you.
Kevin
ok
http://live.datatables.net/poyiyiwu/1/edit
The only thing that I can show you
Please provide a running test case. Like having all the CSS and JS includes, the html table, etc. The example may not run correctly but it should be running so we can help you with the code.
Kevin
I can not, I use an api with personal data, with that data is not enough for an idea?
The API doesn't matter. Use Javascript data to add to the table like the example I linked to earlier. Remove the ajax stuff. All we are interested in is the data and adding it to the table using
data
.Kevin
You don't have to use "personal" data. Invent some data for the test case.
ok
.
ok!
As I mentioned in your other thread you first need to loop through the response and convert the
json_log
JSON string to a Javascript object. The Nested Objects example will show how to access nested data.In your example you have
data: ""
. Instead usedata: null
.Here is the updated example:
http://live.datatables.net/geqequdo/1/edit
Kevin
I try this