0

I am using Codeigniter 3 Wiredesignz HMVC plugin with Datatables. I can call the sAjax source correctly but the Ajax response has base_url () and the file path in it like this 'http://localhost/C:/xampp/htdocs/dcproduction/index.php/admin/datatable'.

My script in the view is like this

$(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);
                                }
                            });
                        }
                    });

                });

How do I remove the file path 'C:/xampp/htdocs' from the request header?

Derek Lim
  • 321
  • 1
  • 3
  • 14
  • Code provided on DT website differs from yours.Check the latest documentation on [datatables.net](https://www.datatables.net/) website. – Tpojka Jan 17 '16 at 13:41

1 Answers1

0

Go to application/config, Change base_url() to

If CI 3.0 - (below 3.0)

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

If in 3.0+ (or above 3.0)

$config['base_url'] = 'http://localhost/dcproduction/';
$config['index_page'] = 'index.php';
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
  • I had already set the base_url() correctly. There are no problems with my normal ajax responses but the error occurs only in datatables responses. – Derek Lim Jan 17 '16 at 07:38