我正在使用带有数据表的 Codeigniter 3 Wiredesignz HMVC 插件。我可以正确调用 sAjax 源,但 Ajax 响应具有 base_url () 和其中的文件路径,如“ http://localhost/C:/xampp/htdocs/dcproduction/index.php/admin/datatable ”。
我在视图中的脚本是这样的
$(document).ready(function () {
var url = '<?php echo base_url(); ?>';
var oTable = $('#dt_customers').dataTable({
"bProcessing": true,
"bServerSide": true,
'type': 'POST',
"sAjaxSource": url+'admin/datatable/',
"oLanguage": {
"sProcessing": "<div class='dvLoading'><img src='<?php echo base_url(); ?>assets/img/ajax-loader.gif'></div>"
},
'fnServerData': function (sSource, aoData, fnCallback) {
//var csrf_value = '<?php //echo $this->security->get_csrf_hash(); ?>';
//aoData.push({name: 'csrf_test_name', value : csrf_value}); //csrf_test_name is defined in config/config.php
$.ajax
({
'dataType': 'json',
'type': 'POST',
'url': sSource,
'data': aoData,
'success':function(res){
alert(res);
},
'error':function(s){
alert(sSource);
}
});
}
});
});
如何从请求标头中删除文件路径“C:/xampp/htdocs”?