0

我正在使用带有数据表的 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”?

4

1 回答 1

0

转到application/config,更改base_url()

如果 CI 3.0 - (低于 3.0)

$config['base_url'] = '';
$config['index_page'] = 'index.php';

如果在 3.0+(或高于 3.0)

$config['base_url'] = 'http://localhost/dcproduction/';
$config['index_page'] = 'index.php';
于 2016-01-17T07:35:00.827 回答