我从 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/