Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

Pass the variable as a data source

$
0
0

Hi,
I am forced to make an ajax call which gives me a bool value that i go to check.
If it is true I create the datatable in js.

Example:

$.ajax({
type: "POST",
url: "myapi.php",
data: {"fl": fl},
dataType: "json",
success: function(data){
if (data.success && data.ln=='ok'){
$(document).ready(function() {
$("#tablefdi").DataTable({
"scrollY": "431px",
"scrollX": "true",
"autoWidth": false,
dataSrc: data.data,
"columns": [
{
"orderable": false,
"data": null,
"defaultContent": ""
},
{ "data": "id" },
{ "data": "sn" },
{ "data": "na" },
{ "data": "tx" },
],
"order": [[2, "asc"]]
});
});
}else{
alert(data.error);
}
});

The data is not loaded. Why?
I tried running the $.parseJSON i got syntax error... :-/

If i make the same call directly from datatable, the data is loaded correctly

Thanks...


Viewing all articles
Browse latest Browse all 2364

Trending Articles