Access the information of an attribute of a json file

Access the information of an attribute of a json file

Coder102Coder102 Posts: 78Questions: 2Answers: 0
edited October 2020 in Free community support

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"

Replies

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    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

  • Coder102Coder102 Posts: 78Questions: 2Answers: 0
    edited October 2020

    Ok

  • Coder102Coder102 Posts: 78Questions: 2Answers: 0
    edited October 2020

    Is private i cant run the code. If you can orient yourself with the photo better

  • kthorngrenkthorngren Posts: 20,292Questions: 26Answers: 4,768

    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

  • Coder102Coder102 Posts: 78Questions: 2Answers: 0
    edited October 2020

    ok

  • kthorngrenkthorngren Posts: 20,292Questions: 26Answers: 4,768

    Please start a test case so we can help you.

    Kevin

  • Coder102Coder102 Posts: 78Questions: 2Answers: 0
    edited October 2020

    ok

  • Coder102Coder102 Posts: 78Questions: 2Answers: 0

    http://live.datatables.net/poyiyiwu/1/edit
    The only thing that I can show you

  • kthorngrenkthorngren Posts: 20,292Questions: 26Answers: 4,768
    edited October 2020

    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

  • Coder102Coder102 Posts: 78Questions: 2Answers: 0

    I can not, I use an api with personal data, with that data is not enough for an idea?

  • kthorngrenkthorngren Posts: 20,292Questions: 26Answers: 4,768
    edited October 2020

    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

  • tangerinetangerine Posts: 3,348Questions: 36Answers: 394

    You don't have to use "personal" data. Invent some data for the test case.

  • Coder102Coder102 Posts: 78Questions: 2Answers: 0
    edited October 2020

    ok

  • Coder102Coder102 Posts: 78Questions: 2Answers: 0
    edited October 2020

    .

  • Coder102Coder102 Posts: 78Questions: 2Answers: 0
    edited October 2020

    ok!

  • kthorngrenkthorngren Posts: 20,292Questions: 26Answers: 4,768

    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 use data: null.

    Here is the updated example:
    http://live.datatables.net/geqequdo/1/edit

    Kevin

  • Coder102Coder102 Posts: 78Questions: 2Answers: 0
    edited October 2020

    I try this

This discussion has been closed.