Working with Datatables. Trying to get work function (which currently works ONLY with GET) with POST.
Based on this discussion I modified this function and got something like below. Now getting error message:
json.aaData is undefined @ line 99
jQuery.post( sSource, aoData, function (data) {
/* Callback processing */
oCache.lastJson = jQuery.extend(true, {}, data);
if ( oCache.iCacheLower != oCache.iDisplayStart )
{
data.aaData.splice( 0, oCache.iDisplayStart-oCache.iCacheLower );
}
data.aaData.splice( oCache.iDisplayLength, data.aaData.length );
fnCallback(data)
},"json" );
}
else
{
json = jQuery.extend(true, {}, oCache.lastJson);
json.sEcho = sEcho; /* Update the echo for each response */
json.aaData.splice( 0, iRequestStart-oCache.iCacheLower ); // <- this line
json.aaData.splice( iRequestLength, json.aaData.length );
fnCallback(json);
return;
}
}
What am I missing? Any suggestion?
It's jQuery.post( sSource, aoData, function (data) {
. You have aoData
, but in the code you reference aaData
. It may be a typo.
So the full code sample you provided, couldn't possibly be the full code, because it's only 75 lines long, and you are getting an error that says you have an undefined property on line 99.
However, you did say that this line:
json.aaData.splice( 0, iRequestStart-oCache.iCacheLower );
is giving you the undefined error. What's happening is you are trying to access the splice function of a property aaData which does not exist on your json object for some reason.
So if you open up your JavaScript console and type json.aaData, you will see that it returns undefined. So whatever is supposed to set the aaData property of the json variable is not doing so. I hope this helps you track down your error.