在mRender数据表中调用Ajax Get函数

在mRender数据表中调用Ajax Get函数,ajax,json,datatables,Ajax,Json,Datatables,我希望在Datatables mRender函数中调用一个ajax函数,该函数将使用来自当前ajax源的id从其他ajax源获取数据 要正确看待这一点,我有: 一个数据表中来自不同客户的申请列表 在这个列表中,我有一个客户id。我希望在表中显示客户名称,而不是客户id。但是客户名称和其他客户详细信息在客户表中,因此这些详细信息不在请购单json数据中。但我有客户Id 我如何使用它在mrender函数中获取客户机名称?例如 {"sTitle":"Client","mData":null,

我希望在Datatables mRender函数中调用一个ajax函数,该函数将使用来自当前ajax源的id从其他ajax源获取数据

要正确看待这一点,我有:

一个数据表中来自不同客户的申请列表

在这个列表中,我有一个客户id。我希望在表中显示客户名称,而不是客户id。但是客户名称和其他客户详细信息在客户表中,因此这些详细信息不在请购单json数据中。但我有客户Id

我如何使用它在mrender函数中获取客户机名称?例如

{"sTitle":"Client","mData":null,
    "mRender":function(data){
    //ajax function     
   }
},
提前谢谢大家,,
问候。

我不相信你应该这样处理你的数据。不过,我在mRender函数中也使用了AJAX数据源,如下所述

    $(document).ready(function(e){
       $('.products').dataTable({
           "bProcessing": true,
           "sAjaxSource":  window.location.protocol + "//" + window.location.hostname + '/product/getAll',
           "aoColumns": [
               { "sTitle": "Pid", "bVisible" : false},
               { "sTitle": "Pname" },
               { "sTitle": "Pprice" },
               {   "sTitle": "Pgroups",
                   "mRender" : function( data, type, full ){
                        console.log( data, type, full );
                        console.log(category.getAll());
                       return 'test';
                   }
               }
            ]
        });
    });
De类别对象在自调用函数中初始化。我用它来防止每次调用函数时远程加载数据。 看起来是这样的:

    (function(){
        if(typeof category === 'undefined'){
            category = {};
        }
        category.getAll = function(){
            if(typeof category.all === 'undefined'){
                $.ajax({
                    'type' : 'POST',
                    'async': false,
                    'url' : window.location.protocol + "//" + window.location.hostname + "/category/getAll",
                    'success' : function(data){
                        console.log(data);
                        category.all = data;
                    },
                    'error': function(a,b,c){
                        console.log("You shall not pass!",a,b,c);
                        alert('stop');
                    }
                });
            }
            return category.all;
        }
    })();

我也在寻找这样做,你解决问题了吗?