如何动态设置dataTable的Ajax URL?
我正在使用jQuery DataTables,我的JavaScript代码如下所示:
$(document).ready(function() { var tbl = $('#table_tabl').DataTable({
responsive: true,
"oLanguage": {
"sUrl": "<?php echo RP_LANG ?>fr_FR.txt",
},
"processing": true,
"serverSide": true,
ajax: "<?php echo RP_SSP ?>server_processing_reservTables.php", // I want to add a parmeter to it dynamically when a select element is selected
"aoColumnDefs": [{
"aTargets": [3],
"mData": 3,
"mRender": function(data, type, full) {
return '<div style="text-align:center;"><a href="RestaurantReservation/reserverTable/' + data + '" title="Réserver"><span class="mif-lock icon"></span></a></div>';
}
}],
"aLengthMenu": [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, "Tout"]
]
});
});
我想根据选择元素的选择值过滤此dataTable:
$("#select_id").on("change", function(){ // set the ajax option value of the dataTable here according to the select's value
});
如何设置ajax
的选项的值dataTable
在on_change
该事件select
根据所选项目选择的元素?
回答:
我找到了 :
$("#salle_code").on("change", function(){ tbl.ajax.url("<?php echo RP_SSP ?>server_processing_reservTables.php?salle_code="+$(this).val()).load();
});
以上是 如何动态设置dataTable的Ajax URL? 的全部内容, 来源链接: utcz.com/qa/408408.html