adding new row on ajax call

adding new row on ajax call

sachin0235sachin0235 Posts: 1Questions: 0Answers: 0
edited November 2012 in DataTables 1.9
Hi All,

I am new to datatable and java script as well. I am trying to draw a table using datatable and my page keeps on checking server for new data on a certain time interval using ajax request. If data is available i have to insert new row as the first one in my existing datatable.

[code]
var refreshId = setInterval(function() {
$.post("/xxx/xxx/xxx/checkOrder",
function(data){
if(!(data === "")) {
$('#order').dataTable().fnAddData(data);
}
});
}, 19000);
[/code]

server return following data -
[code]
["121111152591","New","abc","26-11-2012","2012-11-21","12:22","608.0"]
[/code]

Now the problem is that datatable insert first data string - 121111152591 as individual column in datatable, like - col1 - [, col 2-1, col3-2 and so on. Also in case of multiple rows returned by JSON object datatable failed to render. Can someone please let me know how to fix this?
This discussion has been closed.