插入数据到数据库使用jquery/ajax,我没有得到蚂蚁错误,但值没有插入到用笨数据库,任何错误,我做的手段,请建议我插入数据到数据库使用jquery/ajax,我没有得到蚂蚁错误,但没有插入数据库的值
$(document).ready(function() {
$("#personal-info").click(function() {
e.preventDefault();
var message = $("#message").val();
// var password= $("#password").val();
$.ajax({
type: "POST",
url: "<?php echo base_url(); ?>index.php/Profile_cntrl/buyer_communication",
data: {message: message},
success: function (data)
{
alert('Successfully inserted');
},
error: function()
{
alert('fail');
}
});
});
});
形式
控制器
public function buyer_communication() {
$supp_id = $this->input->post('suppid');
$product_id = $this->input->post('proid');
$cust_id = $this->input->post('custid');
$result1 = $this->Profile_model->fetch_Data($product_id);
$Userid = $this->session->userdata('id');
$result3 = $this->session->userdata('tt');
$data4 = array(
'message' => $this->input->post('message'),
'supplier_id' => $supp_id,
'product_id' => $product_id,
'Customer_id' => $cust_id,
'From' => $result3,
);
$this->Profile_model->buyer_insert($data4);
redirect('welcome/buyermessageview?id=' . $product_id);
}
型号
function buyer_insert($data4) {
$this->db->insert('communication', $data4);
return ($this->db->affected_rows() != 1) ? false : true;
}
2017-06-01
siddu m
+0
index.php/Profile_cntrl/buyer_communication把它放在你的动作中,看看数据是否到了db ....你至少知道你的错误,并且可以纠正它们 –
+0
在侧面注释掉ajax部分,所以它执行一个普通的文章 –