Ajax bind issue
Ajax bind issue
Hi
I am trying to implement DataTables with a ajax/json bind. but I keep getting the issue "Unable to tget the property 'length': from aData. I checked my return data and it looks like it's formatted properly
[code]
{"sEcho":"1","iTotalRecords":14,"iTotalDisplayRecords":14,"aaData":[["FTP Data Collection","Task used for testing","4","3/7/2012","3/7/2012"],["Process Data","Testing FTP Task","3","3/7/2012","3/7/2012"],["Clean Data","Test Data Transform task","1","3/7/2012","3/7/2012"],["Import Data","Test import data task","0","3/7/2012","3/7/2012"],["Process Cube","Test process Cube task","5","3/7/2012","3/7/2012"],["Comfirm ","test alert stakeholders task","2","3/7/2012","3/7/2012"],["Task One","Task used for testing","6","3/7/2012","3/7/2012"],["Task One","Task used for testing","7","3/7/2012","3/7/2012"],["Task One","Task used for testing","8","3/7/2012","3/7/2012"],["Task One","Task used for testing","9","3/7/2012","3/7/2012"],["Task One","Task used for testing","10","3/7/2012","3/7/2012"],["Task One","Task used for testing","11","3/7/2012","3/7/2012"],["Task One","Task used for testing","12","3/7/2012","3/7/2012"],["Task One","Task used for testing","13","3/7/2012","3/7/2012"]]}
[/code]
and the call is like this
[code]
var oTable = $('#tbl).dataTable({
bProcessing: true,
bServerSide: true,
sAjaxSource: "controller/action",
bAutowidth: true,
aaSorting: [[1, 'asc']],
bLengthChange: true,
bFilter: true,
fnServerData: function (sSource, aoData, fnCallback) {
var parameters = requestData;
parameters.Table = {};
for (var x = 0; x < aoData.length; x++) {
var obj = aoData[x];
parameters.Table[obj.name] = obj.value;
}
$.ajax({
url: url,
data: JSON.stringify(parameters),
dataType: "json",
type: "post",
contentType: "application/json; charset=utf-8",
success: function (data, status, xhr) {
fnCallback(data);
},
error: function (xhr, status, error) {
alert(error);
}
});
}
});
[/code]
What am I missing?
Thanks!
I am trying to implement DataTables with a ajax/json bind. but I keep getting the issue "Unable to tget the property 'length': from aData. I checked my return data and it looks like it's formatted properly
[code]
{"sEcho":"1","iTotalRecords":14,"iTotalDisplayRecords":14,"aaData":[["FTP Data Collection","Task used for testing","4","3/7/2012","3/7/2012"],["Process Data","Testing FTP Task","3","3/7/2012","3/7/2012"],["Clean Data","Test Data Transform task","1","3/7/2012","3/7/2012"],["Import Data","Test import data task","0","3/7/2012","3/7/2012"],["Process Cube","Test process Cube task","5","3/7/2012","3/7/2012"],["Comfirm ","test alert stakeholders task","2","3/7/2012","3/7/2012"],["Task One","Task used for testing","6","3/7/2012","3/7/2012"],["Task One","Task used for testing","7","3/7/2012","3/7/2012"],["Task One","Task used for testing","8","3/7/2012","3/7/2012"],["Task One","Task used for testing","9","3/7/2012","3/7/2012"],["Task One","Task used for testing","10","3/7/2012","3/7/2012"],["Task One","Task used for testing","11","3/7/2012","3/7/2012"],["Task One","Task used for testing","12","3/7/2012","3/7/2012"],["Task One","Task used for testing","13","3/7/2012","3/7/2012"]]}
[/code]
and the call is like this
[code]
var oTable = $('#tbl).dataTable({
bProcessing: true,
bServerSide: true,
sAjaxSource: "controller/action",
bAutowidth: true,
aaSorting: [[1, 'asc']],
bLengthChange: true,
bFilter: true,
fnServerData: function (sSource, aoData, fnCallback) {
var parameters = requestData;
parameters.Table = {};
for (var x = 0; x < aoData.length; x++) {
var obj = aoData[x];
parameters.Table[obj.name] = obj.value;
}
$.ajax({
url: url,
data: JSON.stringify(parameters),
dataType: "json",
type: "post",
contentType: "application/json; charset=utf-8",
success: function (data, status, xhr) {
fnCallback(data);
},
error: function (xhr, status, error) {
alert(error);
}
});
}
});
[/code]
What am I missing?
Thanks!
This discussion has been closed.