How to display this Ajax JSON format data in Jquery Datatabes

How to display this Ajax JSON format data in Jquery Datatabes

kiran7881kiran7881 Posts: 6Questions: 3Answers: 0

I am new to Jquery Datatables , please excuse if this is a dumb question . I will getting this JSON format data (values will be changed ) continuously from backend for every 3 seconds

[
    [
        "481.55",
        "10.40",
        "2.21"
    ],
    [
        "561.30",
        "-2.55",
        "-0.45"
    ],
    [
        "368.20",
        "33.45",
        "9.99"
    ]
]

I am using Jquery Datatables to display to refresh the data for every 3 seconds to display the updated records

I am trying it this way , could anybody please help me in how to display this data properly

<script>
$(document).ready(function(){
var table = $("#example").dataTable({
  "bServerSide": true,
  "ajax": "myurl",
  "aoColumns": [{
    "mData":"0",
    "sTitle": "1"
  }]
});
setInterval( function () {
    table.reload();
}, 3000 );
});

</script>


  <table  id="example">
         <thead>
            <tr>
               <th class="hidden-480">LastPrice</th>
               <th class="hidden-480">Volumme</th>
                <th class="hidden-480">SubData</th>
            </tr>
         </thead>
         <tbody>
         </tbody>
      </table>

Answers

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin

    "bServerSide": true,

    You aren't returning the required server-side processing information so that will never work.

    Question: Do you really need server-side processing? Are you using 50k+ rows?

    If not, then remove that option and use ajax.dataSrc and set it to be an empty string. There is an example in the documentation.

    Allan

This discussion has been closed.