1
I am using codeigniter, I needed to execute a function(parm1) of the model in the view, so as recommended I made a request for the controller, in the controller I read the model and call the function.
I am debugging (error_log), inside the method I call in the request.
[controller]
class BaseController extends CI_Controller {
public function getAgendaDate()
{
error_log('herre');
$this->load->model('agenda_model');
$this->agenda_model->getAgendaDate();
}
}
However, I get status 200 ok in the request, but nothing is printed for my log file, hence I conclude that it is not entering the function. In response, from the request I receive my home.php when I should receive the result of a query. Remember that the post got status 200, but did not enter the method I called.
[view]
$.ajax({
url: "basecontroller/getagendadate",
type: "POST", //send it through get method
data: {
date: '02-02-2019'
},
success: function(response) {
console.log(response);
},
error: function(xhr) {
//Do Something to handle error
console.log(xhr)
}
});
Codeigniter 3.1
Does anyone have any idea what’s going on?
Maybe your setup needs to call the index php. before declaring the controller/method (Something like: example.com/index.php/basecontroller/getagendadate). And you cannot conclude that method
getAgendaDate()
is not being called. What if it is being called and not returning anything? Remember to indicate the IC version you are using.– ShutUpMagda
I am working on localhost, http://localhost/project name/index.php/controller/method does not work, I am redirected back to the home page. @Shutupmagda yes I can know, because my error_logs are not printed.
– Pedro Correia
No, you can’t. What do you want to do with
$this->agenda_model->getAgendaDate();
? Where is the exit from thismethod
? Because you don’t show what thismethod
are you doing? If it is returning aarray
or aobject
, your debug will serve no purpose pq there’s no way out. The show won’t do what you want it to do, it’ll do what you tell it to do.– ShutUpMagda