fnreloadajax
fnreloadajax
firozpjmuhammad
Posts: 5Questions: 1Answers: 0
iam using server side processing script and i want to change data in a button click so use fnreload ajax.but one problem it showing pagination part as
"Showing 1 to NaN of NaN entries (filtered from NaN total entries) First Previous 1 2 3 4 5 Next Last"
but it contain only two data. how i solve this problem?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
seems your serverside script doesn't provide the array fields "recordsFiltered" & "recordsTotal" within the reply, thus dt can not process the pagination properly.
without further insight into your code, will be hard to figure out what's wrong :S
fnreloadajax url return
$sec=array(
array("name", "company", "doj", "email", "phone"),
array("name", "company", "doj", "email", "phone")
);
return json_encode(array("aaData" => $sec));
and if modify response like,
$output = array(
'sEcho' => intval($sEcho),
'iTotalRecords' => $iTotal,
'iTotalDisplayRecords' => $iFilteredTotal,
'aaData' => $sec
);
return json_encode($output);
then a popup message show like json format error
If you are getting a JSON error, did you follow the instructions in the tech note that the error links to? What is the return from the server, since it isn't valid JSON?
Also, note that you are returning legacy parameters (
sEcho
etc) rather than the current parameters. Without a test case, I can't say if that is intentional or not.Allan
fnreloadajax code is like,
jQuery.fn.dataTableExt.oApi.fnReloadAjax = function (oSettings, sNewSource, fnCallback, bStandingRedraw)
{
// DataTables 1.10 compatibility - if 1.10 then
versionCheck
exists.// 1.10's API has ajax reloading built in, so we use those abilities
// directly.
if (jQuery.fn.dataTable.versionCheck) {
var api = new jQuery.fn.dataTable.Api(oSettings);
};
modify response like,
$output = array(
'sEcho' => intval($sEcho),
'iTotalRecords' => $iTotal,
'iTotalDisplayRecords' => $iFilteredTotal,
'aaData' => $sec
);
return json_encode($output);
now datatable not refresh table with new data it show old data.
josn format is like,
{sEcho: 1, iTotalRecords: 15, iTotalDisplayRecords: 10,…}
aaData:[["testtteeeeee", "EMP201610065", "04/06/2016", "firoz@gmail.com", "455455454"],…]
0:["testtteeeeee", "EMP201610065", "04/06/2016", "firozpjmuha@gmail.com", "455455454"]
1:["testttest", "EMP201610060", "04/05/2016", "firozpjm@gmail.com", "555555"]
2:["testtesttest", "EMP201610064", "04/05/2016", "5343434", "54333353"]
3:["test testtest", "EMP201610062", "04/05/2016", "firozpj@gmail.com", "5224244"]
4:["testfftest", "EMP201610061", "04/05/2016", "firozpjmuhammad@gmail.com","54545454"]
5:["TESTEE", "EMP20161009", "03/09/2016", "te@ff.gg", "5433535353"]
6:["serinawillamsw", "EMP201610070", "04/07/2016", "we@gmail.com", "1234567890"]
7:["ramut ramu", "EMP201610010", "04/05/2016","firozpjmuhammad@gmail.com","44444"]
8:["kgfjhjhjhjgmnhmn", "EMP201610068", "04/06/2016","firozpjxz@gmail.com", "4545565656"]
9:["fdsfsfdfsfsffdsfsfsf", "EMP201610066", "04/05/2016", "dfsfsfsfs", "dfsffsf"]
10:["Elbin123sssss", "EMP201610069", "04/01/2016", "elb@gmail.com", "1234567890"]
iTotalDisplayRecords:10
iTotalRecords:15
sEcho:1
Can you link to the page so I can debug it please.
clear all errors and one problem fnreloadajax pass 4 request in a single button click.in that one requet is "sAjaxSource" url. how can solve this?
As above, please link to a test case. Also,
ajax.reload()
is the built in function that provides this ability in 1.10+.