Why always NULL value data from Ajax with CURL method in codeigniter?
Here is my error:
A Database Error Occurred Error Number: 23000/515 [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Cannot insert the value NULL into column 'noreg', table 'DBRS_MARGONO.dbo.VKLAIM_VERIF'; column does not allow nulls. INSERT fails. INSERT INTO "VKLAIM_VERIF" ("noreg", "user_id", "verified", "level_verif", "catatan") VALUES (NULL, NULL, NULL, 0, '') Filename: C:/xampp/htdocs/ws/system/database/DB_driver.php Line Number: 691
and here are my controller to print when ajax is called:
$post = array();
$post['noreg'] = $this->input->post('noreg');
$post['user'] = $this->input->post('user');
$post['status'] = $this->input->post('verified');
$url = 'http://localhost/ws/rsms/verifupdatesimpanstatus';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json; charset=utf-8",
"X-API-Key: " . $aksesws['X-API-Key'],
"IDAPP: " . $aksesws['IDAPP'])
);
$de = curl_exec($ch);
$d = json_decode($de, true);
curl_close($ch);
echo $de;
But when I test my post data $post
is sent and I think the problem in CURL POST method. I have been searching solutions and I don't know where is the error. Web service works well when I test it in Postman with POST method x-www-form-urlencoded
Here are my ajax code:
function updateStatusVerif(noreg,user,verified) {
$.post("<?php echo base_url();?>superuser/pasien/updateStatusVerif",
{
noreg : noreg,
user : user,
verified : verified
},
function(data){
$('#btnverif').html(data);
});
}
I send return data value from web service to #btnverif element.