Bug using Async true and stateLoadCallback
Bug using Async true and stateLoadCallback
Hi,
I'm using DataTables 1.10.11 (I cannot upgrade for now)
I'm having an issue with Async true.
The bug was mentionned here
https://datatables.net/forums/discussion/49373#Comment_130295
I'm trying to fix the code manually based with the fixe provided here, but with no luck
https://github.com/DataTables/DataTablesSrc/commit/9c3e8eaa7935eaa5f46f05714ceb6bf2998328f8
The fix does not solved the problem as if I remove "async": false,
from my code it won't load the Datatables values.
So is there another fix that I can applied manually, or maybe a better fix was posted?
stateLoadCallback: function(settings) {
var table49 = "allquotes";
var o;
$.ajax( {
"url": "ASEngine/ASAjax.php?action=load",
"data":{ "user_id":"<?php echo $userId; ?>", "action" : "loadDataTable", "tablename" : table49},
"async": false, // problem
"type": "POST",
"success": function (json) {
o = json;
}
});
if(o){
return JSON.parse(o);
}else{
}
}
This question has an accepted answers - jump to answer
Answers
Is there any reason you can't update. DataTables should be backward compatible.
Colin
Yes of course, here my reasons, if you can help for any of these maybe I would be able to update and have the time to tests, at the moment 4) is the main problem.
or if you can give a solution to fix the old version that would be the faster way for now
1) the application is almost completed and tested that will required a lot of tests,I have 55 tables with lot of custom code that fix previous issues..
2) I did an update to test I got 2 warning issues
https://datatables.net/forums/discussion/63795/pdfmake-warning-failed-to-load-sourcemap
The main issue
https://datatables.net/forums/discussion/63794/colreorder-warning-added-non-passive-event-listener-to-a-scroll-blocking
3) I will need to check if all issues are now fixed or not that can take a lot of time I found several bugs and that took some time to fix them all. I did some test and some of the fix break the actual code for example this old fix
https://github.com/DataTables/Responsive/issues/90#issuecomment-348272358
4) The main problem is I don't know how to update my actual stateLoadCallback from this question to work with the new method
https://datatables.net/forums/discussion/63797/i-need-help-to-update-stateloadcallback-to-new-method#latest
Updates
2) I have fixed pdfmake warning
2) I have not fixed colreaorder waning
3) this bug is still present and my old code fix is not working anymore
4) still looking help to adapt the code
So I beleive I will have to many fix to go through for now with the recent Datatables and probably to many code to adapt ( I started the process but that would take sonme time)
So how can I manually fix the Async true DataTables 1.10.11 for now ?
All I can suggest is to take a look at the fix that Allan made in the thread you link to, and see if you can add that fix into your version of the files.
Colin
The fix provided
https://github.com/DataTables/DataTablesSrc/commit/9c3e8eaa7935eaa5f46f05714ceb6bf2998328f8
does not work on DataTables 1.10.11, What I mean is after applying the fix, if I removed the async false or comment it or use async true = the stateLoadCallback is not loading the data
plus if you read the user comment he seems to said that the fix was causing issue
We don't support old versions, I'm afraid. So you'll either need to upgrade, or retrofit the changes back into your version. It's open source, so you have access to the commit history.
Colin
Ok I understand, I'm in the process to update.
Could you help me with
https://datatables.net/forums/discussion/63797/i-need-help-to-update-stateloadcallback-to-new-method
Hi,
I'm testing my old function on the latest Datatables
This is still work ONLY if Async is set to false.
when it is set to async true this is not working.
I'm trying to us the new method with the callback, but there is no information on how to use it or parse it...
Since Ajax is an asynchronous process you will need to do your processing of the JSON response in the
success
function. if you remove line 9"async": false,
and execute the code as is then the if statement in line 16 is executed before the Ajax response, ie, before thesuccess
function. Move it inside thesuccess
function to have it execute at the proper time.Kevin
Look at the examples in the
stateLoadCallback
. There is an addedcallback
to versions 1.10.13 and newer. You are not using this structure, from the docs:Kevin