Sac*_*yal 0 php ajax jquery datatables
如何使用jQuery DataTables在ajax调用中传递额外的参数?
这是我的代码
$(document).ready(function() {
var dataTable = $('#student-grid').DataTable( {
responsive: {
details: {
renderer: function ( api, rowIdx ) {
var data = api.cells( rowIdx, ':hidden' ).eq(0).map( function ( cell ) {
var header = $( api.column( cell.column ).header() );
return '<p style="color:#00A">'+header.text()+' : '+api.cell( cell ).data()+'</p>';
} ).toArray().join('');
return data ? $('<table/>').append( data ) : false;
}
}
},
processing: true,
serverSide: true,
ajax: "borrowedBookNew.php" // json datasource
} );
} );
Run Code Online (Sandbox Code Playgroud)
我想将一个新参数传递给我的php文件并获得一个新结果.
您可以通过将ajax参数设置为对象来传递其他数据:
$('#student-grid').dataTable({
// ...
ajax: {
url: 'borrowedBookNew.php',
data: {
customField: 'customValue'
}
}
});
Run Code Online (Sandbox Code Playgroud)
您还可以将data接收当前数据的函数作为可以操作的对象传递.这对于添加页面加载时不可用的动态数据特别有用.
资料来源:http://datatables.net/examples/server_side/custom_vars.html
| 归档时间: |
|
| 查看次数: |
1319 次 |
| 最近记录: |