Base url in javascript with codeigniter to load datatable

0

Hello problem is that I am trying to load a datatable through ajax, but it turns out that I get a 404 error.

is my javascript code

function cargardatos(){
  $('#users-table').DataTable({
              "language": {
              decimal: "",
              emptyTable: "No hay información",
              info: "Mostrando _START_ a _END_ de _TOTAL_ Entradas",
              infoEmpty: "Mostrando 0 to 0 of 0 Entradas",
              infoFiltered: "(Filtrado de _MAX_ total entradas)",
              infoPostFix: ",",
              thousands: ",",
              lengthMenu: "Mostrar _MENU_ Entradas",
              loadingRecords: "Cargando...",
              processing: "Procesando...",
              search: "Buscar:",
              zeroRecords: "Sin resultados encontrados",
              paginate: {
                  first: "Primero",
                  last: "Ultimo",
                  next: "Siguiente",
                  previous: "Anterior"
              }
          },
        "ajax": {
          url: '<?php echo base_url();?>admin/usuarios/userslist',
          type: "POST",
        }
      });
}

the error that appears to me is:

POST http://localhost/upa/%3C?php%20echo%20base_url();?%3Eadmin/usuarios/userslist 403 (Forbidden)

and this is my .htaccess configuration

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css|js|docs|syste)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    
asked by Andrés Cantillo 04.10.2018 в 23:00
source

2 answers

0

I already found the solution, what I did was create a route in routes.php

$route['admin/getusers'] = 'admin/usuarios/userslist';

and then call it from ajax using POST :

function cargardatos(){
  $("#users-table").dataTable().fnDestroy();
  $('#users-table').DataTable({
          "language": {
          decimal: "",
          emptyTable: "No hay información",
          info: "Mostrando _START_ a _END_ de _TOTAL_ Entradas",
          infoEmpty: "Mostrando 0 to 0 of 0 Entradas",
          infoFiltered: "(Filtrado de _MAX_ total entradas)",
          infoPostFix: ",",
          thousands: ",",
          lengthMenu: "Mostrar _MENU_ Entradas",
          loadingRecords: "Cargando...",
          processing: "Procesando...",
          search: "Buscar:",
          zeroRecords: "Sin resultados encontrados",
          paginate: {
              first: "Primero",
              last: "Ultimo",
              next: "Siguiente",
              previous: "Anterior"
          }
      },
      "ajax": {
        url: "admin/getusers",
        type: "POST"
      }
      });
}
    
answered by 11.10.2018 / 17:39
source
0

link % 3C ? php

% 3C is being taken as the directory path, that character should not be coded to url_encode, you are the one who knows the route where you want to send the request, but make sure that% 3C is used literally.

    
answered by 05.10.2018 в 02:40