Ajax Bug when connection time out
Ajax Bug when connection time out
lazzy
Posts: 21Questions: 8Answers: 0
i got bug .length is not a function when server not return object
line 4732 file jquery.dataTables.js
// Got the data - add it to the table
for ( i=0 ; i<aData.length ; i++ ) {
_fnAddData( settings, aData[i] );
}
we can fix it
if($.isArray((aData)){
for ( i=0 ; i<aData.length ; i++ ) {
_fnAddData( settings, aData[i] );
}
}
This discussion has been closed.
Answers
Correct - the server needs to return an array for DataTables 1.10. If there is no data, then it should be returning an empty array. I'm afraid I don't consider this to be a bug.
Having said that, this is something that will change in the next major version of DataTables. The absence of data will also be treated as no data, rather than as an error.
Allan
but if aData = null or undefined aData.length is break it can't continue
Hello Lazzy,
I also had that issue with session timeout, i resolve it with that piece of code
it's notreally perfect but it works for me :-)
Correct. That's why I said it needs to be an empty array and not either
null
orundefined
. If there is no data, then DataTables currently expects that to be explicitly the case by there being an empty array.Allan