尝试使用ajax和php将参数发送到mysql?我之前在我的项目中已经完成了这个但是由于某种原因这不起作用
查看:
$(document).on('click','#btnbehvoegtoe',function(){
var klacht = $('#lijstbeh_klacht').val();
var diagnose = $('#lijstbeh_diagnose').val();
var beh = $('#lijstbeh_behandeling').val();
var behkort = $('#lijstbeh_behandelingkort').val();
alert(patid);
alert(klacht + diagnose + beh + behkort);
$.ajax({
type: 'POST',
url: 'behandelingen/addbehandeling',
datatype : 'JSON',
data: { BEH_PA_ID : patid,
BEH_klacht : klacht,
BEH_diagnose : diagnose,
BEH_behandeling : beh,
BEH_behandelingkort : behkort
},
success : function(){
alert("De behandeling is toegevoegd");
}
});
});
控制器
public function addbehandeling()
{
$this->load->model('behandelingen_model');
$this->behandelingen_model->addbehandeling();
}
模型
function addbehandeling()
{
$BEH_PA_ID = $this->security->xss_clean($this->input->post('BEH_PA_ID'));
$BEH_klacht = $this->security->xss_clean($this->input->post('BEH_klacht'));
$BEH_diagnose = $this->security->xss_clean($this->input->post('BEH_diagnose'));
$BEH_behandeling = $this->security->xss_clean($this->input->post('BEH_behandeling'));
$BEH_behandelingkort = $this->security->xss_clean($this->input->post('BEH_behandelingkort'));
$data = array(
'BEH_PA_ID' => $BEH_PA_ID,
'BEH_klacht' => $BEH_klacht,
'BEH_diagnose' => $BEH_diagnose,
'BEH_behandeling' => $BEH_behandeling,
'BEH_behandelingkort' => $BEH_behandelingkort,
'BEH_datum' => date('Y-m-d')
);
$this -> db -> insert('behandelingen', $data);
}
警报有效 Firebug的参数为POST以及