Using a variable for sAjaxSource

Using a variable for sAjaxSource

KronomKronom Posts: 1Questions: 0Answers: 0
edited May 2013 in General
I have been struggling with this problem. I want to use a variable that has a Json. I'm using it like this:

[code]
$(document).ready(function () {
var getlist = '<%=output%>';

$('#datatables').dataTable({
"bProcessing": true,
"sAjaxSource": getlist,
"sAjaxDataProp": "people",
"aoColumns": [
{ "mDataProp": "id_name" },
{ "mDataProp": "name" },
{ "mDataProp": "lastname" },
]
});

I have used alert(getlist) and it displays the Json so I know that is working, but there's no info inside the table. Please, if you know how to solve this, I would appreciated it.

Thanks.

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    sAjaxSource expects a string - telling DataTables where to get the data. Not a Javascript object - it will likely give an error I would think...

    If you want to pass data to the table to use during initialisation, use aaData .

    Allan
This discussion has been closed.