I am working with codeigniter.I have a controller called "User" and in that controller i have a method called "apply" which is bound to a form .With my ajax i am trying to implement a post request but in return i get internal server error 500 error .How i can fix this.I have my index.php page removed by an .htaccess file
$.ajax({
url:'http://localhost/mycodeigniter/ci/user/apply',
type:'POST',
data:{
start:'3/3/2012',
end :'4/3/2012',
reason:'sick'
},
success: function( data, textStatus, jQxhr ){
alert( data );
},
error: function( jqXhr, textStatus, errorThrown ){
alert( 'baler '+errorThrown );
}
});
Try access vía url to method:
http://localhost/mycodeigniter/ci/user/apply
Or try http://localhost/mycodeigniter/index.php/ci/user/appl
Since you're not using HMVC
, you should typically access your controller's methods like this:your-local-project-path/controller-name/method-name
So, the above request should work at following URL http://localhost/mycodeigniter/user/apply
This may help you
/*
|my sql date formate is 2012-3-4
|and if not then first check your date in mysql and change your date according to this "date()" method |used below
*/
public function get_detail()
{
$start = $this->input->post('start');
$end = $this->input->post('end');
$reason = $this->input->post('reason');
$start_date = date('Y-m-d',$start);
$end_date = date('Y-m-d',$end);
/*Pass data in model through function */
$data = $this->model_name->function_name($start_date,$end_date,$reason);
}