I am using dataTable jquery plugin with server side processing enabled. While using fnReloadAjax
function, there is a delay of 2-3 seconds between hiding of the processing div and display of the new data. Here is a post regarding this problem.
I found out that this is due to multiple server requests made by datatable.
In my page onchange
event of a set of radio buttons is making a call to server for new data as follows
oTable.fnReloadAjax("getCaseList?caseStatus=xxx&showValidOnly=true");
In the firebug console I see two requests being made one after the other
GET https://localhost/getCaseList?caseStatus=xxx&showValidOnly=true&_=1363611652185
GET https://localhost/getCaseList?caseStatus=xxx&showValidOnly=true&sEcho=4&iColumns=9&sColumns=&iDisplayStart=0&iDisplayLength=100&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=true&sSearch_4=&bRegex_4=false&bSearchable_4=true&sSearch_5=&bRegex_5=false&bSearchable_5=true&sSearch_6=&bRegex_6=false&bSearchable_6=true&sSearch_7=&bRegex_7=false&bSearchable_7=true&sSearch_8=&bRegex_8=false&bSearchable_8=true&iSortingCols=1&iSortCol_0=4&sSortDir_0=desc&bSortable_0=false&bSortable_1=true&bSortable_2=true&bSortable_3=true&bSortable_4=true&bSortable_5=true&bSortable_6=true&bSortable_7=true&bSortable_8=true&_=1363611701804
The processing div is getting hidden after the completion of first request but new data is loaded only after the second request is complete.
Why is datatable making that second extra call?
Server side requests are issued by the internal
_fnAjaxUpdate
function, which is called from_fnDraw
.This means you are probably calling some method that needs to redraw the table, like a sort or a search, which issues that additional request.
I have been running into the same problem. In my case also i have been using server side processing. After the datatable was initialized, I had written the below statements to hide some columns
And I realized it was requesting 4 times. Then I removed these lines and the the problem of multiple request was solved in my case. How ever if you want to still hide the columns, there is another approach by adding a class ('sClass':'hidden') which sets "display:none" to the column in the column definition of datatable.
Hope this helps. Thanks