I have a service running for static pages on CodeIgniter and now I want to make it dynamic using Ajax calls, but the Ajax call always returns as 404 error (defined by the alert on the error section). The index method of the controller is accessible. Only the _get_procs method returns 404.
My Javascript:
$(document).ready(function(){
base_url = '<?= base_url() ?>';
$('#btnAjax').click(function(){
alert("AJAX");
$.ajax({
url: base_url + 'general-data/_get_procs',
type: 'POST',
data: {'period': '1'},
dataType: 'json'
}).success(function(response){
alert(response);
}).error(function(e){
alert("Error");
});
});
});
My Controller:
function _get_procs(){
$period = $this->input->post('period');
echo json_encode("OK");
}