Jquery 数据表插件 - sAjaxSource

标签 jquery web-services datatables

我从 asp.net Web 服务获取数据,我想知道是否有一种方法可以将该数据(直接从 Web 服务以 json 格式)传递到 DataTables 对象中。我想做这样的事情:

$(document).ready(function() {
    $('#example').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "http://localhost/WebService/GetData",
    } );
} );

最佳答案

是的,你可以做到。这是你的意思吗?...将数据传递到服务器?

$(document).ready(function() {
    $('#example').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "../examples_support/server_processing.php",
        "fnServerData": function ( sSource, aoData, fnCallback ) {
            /* Add some extra data to the sender */
            aoData.push( { "name": "more_data", "value": "my_value" } ); // this line will give additional data to the server...
            $.getJSON( sSource, aoData, function (json) { 
                /* Do whatever additional processing you want on the callback, then tell DataTables */
                fnCallback(json)
            } );
        }
    } );
} );

关于Jquery 数据表插件 - sAjaxSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2134298/

相关文章:

javascript - jQuery - IE6 问题与 javascript 和加载 ajax 的内容

javascript - Jquery 鼠标滚轮事件仅适用于 Chrome

c# - 使用 jQuery 调用 Web 服务

android - android 中的 java.io.FileNotFoundException

php - 使用来自 jquery 数据表的 ajax 调用发送参数

javascript - 如何在 PhoneGap 中使用 Magento API Soap Web 服务

javascript - 将 anchor 标记与特定的 href 相匹配

android - Web服务SocketTimeOutException导致数据库不一致

jquery - 如何使用 Select2 设置数据表长度选择元素的样式

javascript - 如何在ajax响应后重绘数据表