Not displaying JSON data

Not displaying JSON data

kumarshbkumarshb Posts: 2Questions: 0Answers: 0
edited April 2012 in DataTables 1.9
Hi,
I am trying to display the JSON data provided in the download folder and called 'package.json'. However, it displays a blank page. Below is a code. 'result' variable is equal to the JSON data provided and it is set correctly.


[code]
$(document).ready(function() {
$('#example').dataTable(result);
} );




[/code]

What am I doing wrong?

Thanks!

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    The parameter passed to DataTables is an initialisation object - not the data. The initialisation options are all listed here: http://datatables.net/ref . The one in particular that will be of interest to you is aaData - also note this article will likely be of interest to you: http://datatables.net/blog/Extended_data_source_options_with_DataTables

    Allan
  • kumarshbkumarshb Posts: 2Questions: 0Answers: 0
    Thanks! I modified it but still having issues. Below is the code:
    [code]

    var input="{ 'aaData': [SOME_JSON_DATA_FROM_OUTSIDE], 'aoColumns': [{ 'sTitle': 'Title', 'mDataProp': 'title' ]} ";

    $(document).ready(function() {
    $('#example').dataTable(input);
    });



    [/code]

    I receive JSON data from a function and then create an "input" string with everything added. However, If I manually put inside dataTable() everything - then it works fine. How can I make so that I can just pass in the input received from the function?

    Thanks.
This discussion has been closed.