Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82198

Problem with async stateLoadCallback

$
0
0

Hello Friends,
Please, I have big trouble with async stateLoadCallback.
When I use this call the script in section $(document).ready(function () stop correct work.
I mean this code for call

        "stateLoadCallback" : function(settings, callback){
            $.ajax({
                url: 'helpari/db_state_load.php?listId=' + $('input[id=listId]').val()
                , dataType: 'json'
                , success: function (json) {
                     console.log(json);
                     callback(json);
                }
                , error: function () {
                    callback(null);
                    beginner = 1;
                    console.log("Not completed Load stateCallback")
                }
            });
        },

And here is the code which is prepared in $(document).ready(function () section

$(document).ready(function () {
        var DataTableBody = $('#dataTable tbody');
        console.log(DataTableBody);
        $('.leftmenutrigger').on('click', function (e) {
            $('.side-nav').toggleClass("open");
            e.preventDefault();
        });

  // prepare PDF view
        DataTableBody.on('click', '#PDFMaker', function (){
            var rsp, pathT;
            var data = oTable.row($(this).parents('tr')).data();
            var XMLFile = data['msg_link'];
            var myData = "filename=" + XMLFile;

            // Volame PDF maker
            $.ajax({
                type: "GET",
                url: "helpari/show_pdf_new.php",
                dataType: "text",
                data: myData,
                success: function (response) {
                    // alert(response);
                    rsp = response.split(":");
                    pathT = "helpari/" + rsp[1] + ".pdf";
                    opendialog(pathT, "PDF náhled");
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert(thrownError);
                }
            });
        });

So, but If I user the SYNC call as you can see in the another code, all works Okay, but in the Console I see the error message about synchonized XMLHttpRequest, that it is OLD in the main thread.

        "stateLoadCallback" : function(settings, callback){
            var o;
            $.ajax({
                url: 'helpari/db_state_load.php?listId=' + $('input[id=listId]').val()
                , dataType: 'json'
                , async: false
                , success: function (json) {
                    o = json;
                }
                , error: function () {
                    callback(null);
                    beginner = 1;
                    console.log("Nepovedl se Load stateCallback")
                }
            });
            return o;
        },

Please, Where is the problem?
Why doesn't it work correctly with asynchronous call of the loadStateCallback?
Thanks a lot for help
Honza H


Viewing all articles
Browse latest Browse all 82198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>