'json is null' error on infinite scrolling
'json is null' error on infinite scrolling
I'm using allan's code for infintite scrolling: http://datatables.net/examples/api/infinite_scroll.html
When there are rows in the result they show up without problems, however when the server returns an empty aaData array the DataTable keeps showing the 'Loading...' message and there's a Javascript error 'json is null'.
I can catch this error by checking the length of the array, however shouldn't a proper message show up automatically?
Can anybody help?
[code] var oTable, oSettings, oHeader;
var oLoadParams = {
iDataStart: 0,
iDataLength: 10,
iLock: false
};
function fnAddAjaxData()
{
oLoadParams.iLock = true;
$.getJSON(
oTable.fnSettings().sAjaxSource,
{"iStart": oLoadParams.iDataStart, "iLength": oLoadParams.iDataLength, "action": "products", "pId": 2},
function(json) {
for (var i = 0; i < json.aaData.length; i++) {
// create result
}
oTable.fnAddData(json.aaData);
oLoadParams.iDataStart = oLoadParams.iDataStart + json.aaData.length;
oLoadParams.iLock = false;
}
);
}[/code]
Thanks
When there are rows in the result they show up without problems, however when the server returns an empty aaData array the DataTable keeps showing the 'Loading...' message and there's a Javascript error 'json is null'.
I can catch this error by checking the length of the array, however shouldn't a proper message show up automatically?
Can anybody help?
[code] var oTable, oSettings, oHeader;
var oLoadParams = {
iDataStart: 0,
iDataLength: 10,
iLock: false
};
function fnAddAjaxData()
{
oLoadParams.iLock = true;
$.getJSON(
oTable.fnSettings().sAjaxSource,
{"iStart": oLoadParams.iDataStart, "iLength": oLoadParams.iDataLength, "action": "products", "pId": 2},
function(json) {
for (var i = 0; i < json.aaData.length; i++) {
// create result
}
oTable.fnAddData(json.aaData);
oLoadParams.iDataStart = oLoadParams.iDataStart + json.aaData.length;
oLoadParams.iLock = false;
}
);
}[/code]
Thanks
This discussion has been closed.