i want to insert data using Ajax to databse. But I got 500 Internal Server Error. After I check I get Call to undefined method Hire_model::InserData(). Can anyone help me to correct my code. Any help is appreciated Thanks!
$('#button-smt').click(function(){
var form_data = $('#myform').serialize();
$.ajax({
url:"<?php echo base_url('Hire/submit_hire');?>",
method:"POST",
data:form_data,
success:function(data){
console.log(data);
if (data.status) {
alert('sukses!');
}
},
error:function(){
alert('error ... ');
//console.log(data);
$('#myModal').hide();
$('.modal-fade').hide();
$(".modal-backdrop").remove();
}
});
});
My Controller
public function submit_hire(){
$total = $this->input->post('total');
$workdate = $this->input->post('workdate');
$data = array(
'NumberOfPlacement' => $total,
'ExpectedWorkStartDate' => $workdate
);
$res = $this->hire_model->InserData('dbo.RequisitionTable' , $data);
if ($res) {
echo json_encode(array('status'=>true));
}else
echo json_encode(array('status'=>false));
}
My Model
public function InsertData($tabelName, $data){
$res = $this->db->insert($tabelName, $data);
return $res;
}