SAjaxsource在JQuery Datatables中完成后如何调用javascript函数

Ara*_*asu 3 javascript jquery datatables

我正在使用JQuery SAjaxsource如何在SAjaxsource完成后调用javascript函数.我想在完成数据表加载后更新一个div.请帮帮我...

编辑:

$(document).ready( function() {
                var oTable = $('#example').dataTable( {

                    "bServerSide": true,
                                    "sSearch":false,
                                    "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
                                    "bPaginate": true,
                                    "bJQueryUI": true,
                                    "sPaginationType": "full_numbers",
                                    "sAjaxSource": "server_processingCDB1.php"
                } );
Run Code Online (Sandbox Code Playgroud)

Man*_*eUK 6

看一下帮助的回调部分中的fnServerData选项 - > http://www.datatables.net/usage/callbacks

为您提供所需的一切......这里有一些示例代码:

$(document).ready(function() {
    $('#example').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "../examples_support/server_processing.php",
        "fnServerData": function ( sSource, aoData, fnCallback ) {
            $.getJSON( sSource, aoData, function (json) { 
                /* Do whatever additional processing you want on the callback, then tell DataTables */
                fnCallback(json)
            } );
        }
    } );
} );
Run Code Online (Sandbox Code Playgroud)


小智 6

http://datatables.net/ref#fnDrawCallback也适用于此,并保存您需要覆盖 fnServerData 的情况。

参数: fnDrawCallback

类型:函数

输入: {object}:DataTables 设置对象

该函数会在每个“绘制”事件中调用,并允许您动态修改所创建的 DOM 的任何方面。

$(document).ready( function() {
  $('#example').dataTable( {
    "fnDrawCallback": function( oSettings ) {
      alert( 'DataTables has redrawn the table' );
    }
  } );
} );
Run Code Online (Sandbox Code Playgroud)