Single AJAX call for all tables

Single AJAX call for all tables

jonmrichjonmrich Posts: 12Questions: 6Answers: 0
edited January 2015 in Free community support

I'm using something like to to get the data I need.

var all_data;

    $.ajax({
            async   : false,
            url: 'all_data.php',
            type: 'GET',     
            success: function(data) {
            
            all_data = data;
             console.log(all_data);
}
         
  })

The idea is to pass this into my table function (I have several on this one page) without having to make multiple calls. Doing the following returns one column with the letter "a", which isn't right. The data that comes back is JSON coded. I've used the blow code, but with the AJAX function as part of the table function:

     ``` 
      $("#my_table").DataTable({
      "data":[all_data]
       ,
      "paging":        true,
      "sDom": '<"top">t<"bottom"><"clear">',
      "pageLength": 50,
      "order": [[ 4, "desc" ]],
      "aoColumns": [
      { "bSortable": true, "width": "0%", "sClass": "lang_body_2", "sTitle": "","visible":false },
      { "bSortable": true, "searchable": false, "width": "10%", "sClass": "lang_body_2 table_names", "sTitle": "" },
      { "bSortable": true, "searchable": false,"width": "20%", "sClass": "lang_body_2",  "sTitle": "Database","visible":false},
      { "bSortable": true, "searchable": false ,"width": "20%","sClass": "lang_body_2","sTitle": "National Average","visible":false },
      { "bSortable": true, "searchable": false ,"width": "50%","sClass": "lang_body_2 index_num table_index","sTitle": "" },
      ],
      "columns": [
      { "searchable": true },
      { "searchable": false },
      { "searchable": false },
      { "searchable": false },
      { "searchable": false },
      ],
      "search": {
      "search": "gen"
      },
      "columns": [
      { "width": "20%" },
      null,
      null,
      null,
      { "width": "80%" },
      ],
      "initComplete": function(settings, json) {
        colorIndex();}

      });

});

```

What am I missing here?

This discussion has been closed.