xhr and csrf - Delay problem ( Bug ? )
xhr and csrf - Delay problem ( Bug ? )
I have a problem with this code ...
`var oTable = table.DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "urlpage/getReport",
"type": "POST",
"data": function ( d ) { return $.extend( {}, d, { "csrf_token": formTokenValue } ); }
},
'iDisplayLength': 5,
"order": [[ 0, "desc" ]],
"processing": false, // I use lockPage(true); to put an custome overlay with a loading that avoid click on next ...
"columns": [
{ "data": "id" },
{ "data": "nick" },
{ "data": "fullname" },
{ "data": "status" }
],
"lengthMenu": [[5, 10, 25, 50, 100], [5, 10, 25, 50, 100]],
"preDrawCallback":function(){ lockPage(true); // Lock to avoid the user click on next until finish },
"drawCallback": function(a){
lockPage(false); // Unlock the page its loaded so they can hit next now
}
});
oTable.on('xhr.dt', function ( e, settings, json, xhr ){
//lockPage(false); // I also try unlock here with the same result
formTokenValue = oTable.ajax.json().formToken;
});`
My problem its that it works fine with 5 rows (even with 25), the call its so fast that the user didnt hit next that fast to trigger this problem, but when i set 100 rows it seems to be a little delay betteen the first call and the second so if the user hit that fast (like miliseconds) didnt update the formtoken that fast and when the second call its trigger then fails (cuz didnt have the refresh token from the first call - server security error) so i supposeded that xhr it has some kind of delay and so it is, i check the network calls on my browser and when send a network call (the first one) call gets the response but there's like less than a seccond delay to change that call status to 200 ...
Its there an definitive status or event that triggers when its fully finished ajax / draw ?? because its not an option to disable csrf token