Trouble Getting Started

Trouble Getting Started

simplysethsimplyseth Posts: 3Questions: 2Answers: 0

on my server '/ec2' gives me the below JSON output:

{
  "data": {
    "i-012a8a09": {
      "_in_monitoring_element": false,
      "_previous_state": "",
      "account": "RIQP04",
      "ami_launch_index": "0",
      "architecture": "x86_64",
      "client_token": "coAmR1400016170091",
    },
    "i-013782f7": {
      "_in_monitoring_element": false,
      "_previous_state": "",
      "account": "RIQP01",
      "ami_launch_index": "0",
      "architecture": "x86_64",
      "client_token": ""
    }
}

on my html page I have:

<script src="{{ url_for('static', filename='js/jquery.min.js')}}"></script>
<script src="{{ url_for('static', filename='js/bootstrap.js')}}"></script>
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script>
<script>
$(document).ready(function() {
       $('#ec2_table').DataTable({
        "ajax": 'http://127.0.0.1:5000/ec2'
    });
});
</script>
<table id="ec2_table" ></table>

The error I get is:

Uncaught TypeError: Cannot read property 'aDataSort' of undefined
jquery.dataTables.min.js:63 
Tjquery.dataTables.min.js:67 
xajquery.dataTables.min.js:91 (anonymous function)
jquery.min.js:2 m.extend.eachjquery.min.js:2 
m.fn.m.eachjquery.dataTables.min.js:82 
ojquery.dataTables.min.js:157 
h.fn.DataTable(index):58 (anonymous function)
jquery.min.js:2 
m.Callbacks.jjquery.min.js:2 m.Callbacks.k.fireWithjquery.min.js:2 
m.extend.readyjquery.min.js:2 

I'm not quite understanding what I'm missing to get this running.
Thanks.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Answer ✓

    Have a look at this part of the manual about loading data from objects.

    One thing about your data format, you will probably need to modify it a little since each row has a unique property name. You could use functions to handle that, but it would be easier if you just returned an array of objects with the data there.

    Allan

This discussion has been closed.