简体   繁体   中英

jQuery Datatables resume after AJAX call completed

I am using the Datatables plugin for jQuery, and I am trying to figure out how to resume the script once the AJAX call was successfull.

My current code is:

var table = $("#dataTables-example").DataTable(
        {
            ajax: {
                url: "/kleurmixer/hmi/view_json2.php?type=2",
                dataSrc: '',
            },
            "aoColumnDefs": [
                { 'bSortable': false, 'aTargets': [ 7 ] },
                { 'bSortable': false, 'aTargets': [ 8 ] }
            ]
        }
);

Now, in Chrome and FF it works. But since this is a page made for WinCC (which uses IE7), it doesn't work. So I need some kind of callback function for my AJAX call, but I can't figure out how to do it.

Help would be appreciated,

Thanks,

You could create a callback for done or success like this. You could also add error and statusCode if you need that.

var table = $("#dataTables-example").DataTable(
    {
        ajax: {
            url: "/kleurmixer/hmi/view_json2.php?type=2",
            dataSrc: '',
            "done": function(){
                alert('done');
            }
        },
        "aoColumnDefs": [
            { 'bSortable': false, 'aTargets': [ 7 ] },
            { 'bSortable': false, 'aTargets': [ 8 ] }
        ]
    }
);

Update 1: Another datatable approach

$("#dataTables-example").dataTable( {
    "initComplete": function(settings, json) {
      alert( 'DataTables has finished its initialisation.' );
    }
} );

Documentation for Datatables initComplete

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM