Ajax question

Ajax question

hammurabihammurabi Posts: 3Questions: 0Answers: 0
edited April 2012 in General
So, say I have some code that looks like this:

[code]

$.ajax({
type: "POST",
url: ".../broker",
data:"_debug=0&_program=@sas_prog_prefix@get_ids_test.sas&_service=@sas_intrnet_service@&subject_id=" + $.trim($(this).find("#systemIDCell").text()),
dataType: "json",
success: function( data ){

$('#table_id').dataTable( {
"bProcessing": true,
"sAjaxSource": data.aaData,
"aoColumns": [
{"mDataProp": "id"},
{"mDataProp": "id_info_desc"}
]


});

});
}
});

[/code]

I'm trying to load the json result into dataTables without much success. Could someone help me a little? Do I have the initialization in the wrong spot? The data is being returned correctly, but I can't get it to display in the table.

Replies

  • allanallan Posts: 63,810Questions: 1Answers: 10,516 Site admin
    Almost I think - but rather than giving your data array as sAjaxSource, give it as aaData . sAjaxSource would make DataTables do the Ajax request, but you've already done that :-)

    Allan
  • hammurabihammurabi Posts: 3Questions: 0Answers: 0
    My json data comes back like this

    [code]
    {
    "aaData": [
    {"id":"3303925","id_info_desc":"ID 1"}
    ,
    {"id":"12345678","id_info_desc":"ID 2"}
    ]
    }
    [/code]
This discussion has been closed.