在datatable ajax调用中成功调用函数 [英] call a function in success of datatable ajax call

查看:387
本文介绍了在datatable ajax调用中成功调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在datatable ajax调用中成功调用javascript函数。
以下是我尝试使用的代码,

Is that possible to invoke a javascript function in success of datatable ajax call. Here is the code am trying to use,

var oTable = $('#app-config').dataTable(
            {
                "bAutoWidth": false,                                                
                "bDestroy":true,
                "bProcessing" : true,
                "bServerSide" : true,
                "sPaginationType" : "full_numbers",
                "sAjaxSource" : url,                    
                "fnServerData" : function(sSource, aoData, fnCallback) {
                    alert("sSource"+ sSource);
                    alert("aoData"+ aoData);
                    $.ajax({
                        "dataType" : 'json',
                        "type" : "GET",
                        "url" : sSource,
                        "data" : aoData,
                        "success" : fnCallback
                    });
                }

是否有类似的东西,

success : function(){
    //.....code goes here
}

而不是成功:fnCallback - ----->这是AJAX调用的最后一行。
在这个函数中,我想检查从服务器端发送的值。
提前感谢您的帮助......

instead of "success" : fnCallback ------> which is last line of AJAX call. In this function I would like to check a value send from server side. Thanks in advance for any help....

推荐答案

您可以使用dataSrc:

You can use dataSrc :

以下是datatables.net的典型示例

Here is a typical example of datatables.net

var table = $('#example').DataTable( {
    "ajax": {
            "type" : "GET",
            "url" : "ajax.php",
            "dataSrc": function ( json ) {
                //Make your callback here.
                alert("Done!");
                return json.data;
            }       
            },
    "columns": [
            { "data": "name" },
            { "data": "position" },
            { "data": "office" },
            { "data": "extn" },
            { "data": "start_date" },
            { "data": "salary" }

        ]
    } );

这篇关于在datatable ajax调用中成功调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆