I'm having some issues trying to load a function from a JS in a view page. It works with others view page, but for some reason this one called sistemas_aplicaciones doesn't work, it can't find the controller in order to show the view page.
This is the submenu view that calls the function in controller.
This view page will generate some buttons based on the id_menu loaded from a database called menu. when you click the agregar button it will execute a JS that will take the href and enter in the controller function create.
The function will return an array of the view page of sistemas_aplicaciones and show it in the #principal tag.
Like I said, this is working for the other controllers and view page in my project, but for sistemas_aplicaciones doesn't work, its showing an ajax error 404 not found. Can someone help me to understand why?
This is the submenu view that calls the function in controller.
Code:
<?php
defined("BASEPATH") OR exit("No direct script access allowed");
?>
<script type="text/javascript" src="<?php echo base_url('assets/js/helper/func_administracion.js');?>"></script>
<ul class="nav nav-stacked" id="accordion" role="tablist" aria-multiselectable="true">
<input type="hidden" id="id_menu_superior" value="{id_menu_superior}"/>
<input type="hidden" id="vista" value="{vista}"/>
<li class="active" id="0" role="tab" >
<a href="<?= base_url('{vista}/load_default_content')?>" id="call_default">
<span><?= img(base_url("assets/img/ico12_treeleaf.gif"),FALSE)?> </span>
Acerca del Módulo {menu_superior}
</a>
</li>
{submenu}
<li class="panel" id="{id_menu}" >
<a role="button" data-toggle="collapse" data-parent="#accordion"
href="#submenu_{id_menu}" aria-expanded="true" aria-controls="submenu_{id_menu}">
<?= img(base_url("assets/img/1x1.gif"),FALSE,array("id"=>"folder_{id_menu}","class"=>"plus"))?>
<?= img(base_url("assets/img/ico12_treefolder.gif"),FALSE)?>
{nombre}
</a>
<ul id="submenu_{id_menu}" class="nav collapse" role="tabpanel" aria-labelledby="{id_menu}">
<li style="padding-left: 15px;">
<!-- Here is where you call the controller function -->
<a href="<?= base_url('{vista}/create')?>" name="sub_m_{id_menu}_create" id="sub_m_{id_menu}_create" >
<span><?= img(base_url("assets/img/ico12_treeleaf.gif"),FALSE)?> </span>
Agregar
</a>
</li>
<li style="padding-left: 15px;">
<a href="<?= base_url('{vista}/search')?>" name="sub_m_{id_menu}_search" id="sub_m_{id_menu}_search">
<span><?= img(base_url("assets/img/ico12_treeleaf.gif"),FALSE)?> </span>
Consultar
</a>
</li>
</ul>
</li>
{/submenu}
</ul>This view page will generate some buttons based on the id_menu loaded from a database called menu. when you click the agregar button it will execute a JS that will take the href and enter in the controller function create.
Code:
$("ul.nav.collapse a").on("click", function(){
$.ajax({
type: 'POST',
url: $(this).attr("href"),
data: {},
dataType: 'json',
// Mostramos un mensaje con la respuesta de PHP
success: function(data) {
$('#principal').html(data.mensaje);
},
error: function(error){
$('#principal').html('<div class="alert alert-warning alert-dismissible" role="alert">'+
'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'+
'<strong>Error!!!</strong> Solicitud de AJAX no completada->'+error.status+'</div>');
}
}) ;
return false;
});
});The function will return an array of the view page of sistemas_aplicaciones and show it in the #principal tag.
Like I said, this is working for the other controllers and view page in my project, but for sistemas_aplicaciones doesn't work, its showing an ajax error 404 not found. Can someone help me to understand why?