**Inserting data in to database using jquery/ajax,i am not getting ant error but values not inserting in to the database using codeigniter,any mistake i done means please suggest me**

```
<script type="text/javascript">
        $(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');
                    }
                });
            });
        });
    </script>

```

**form**

```
<form class="form-horizontal" method="POST" id="personal-info"  role="form" action="#"> 
                            <div class="panel-footer">
                                <div class="input-group">

                                    <input type ="hidden" name="suppid" id="suppid" value="<?php echo $row->supplier_id; ?>" class="form-control" />
                                    <input type ="hidden" name="proid" id="proid" value="<?php echo $row->product_id; ?>" class="form-control" />
                                    <input type ="hidden" name="custid" id="custid" value="<?php echo $row->Customer_id; ?>" class="form-control" />

                                    <input id="messagee" name="message" type="text" class="form-control input-sm chat_input" placeholder="Write your message here..." />
                                    <span class="input-group-btn">
                                        <button class="btn btn-primary btn-sm" id="submit-p" name="submit-p">Send</button>
                                        <!--<input type="submit" name="submit-p" id="submit-p" value="send" class="btn btn-primary btn-sm" >-->
                                    </span>
                                </div>
                            </div>
                        </form>

```

**controller**

```
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);
}

```

**Model**

```
function buyer_insert($data4) {
        $this->db->insert('communication', $data4);
        return ($this->db->affected_rows() != 1) ? false : true;
    }

```