php – How do i insert data using ajax in JQGrid with CI?-ThrowExceptions

Exception or error:

i try to learn JQGrid but i still dont understand how to insert/edit/delete using ajax from JQGrid i try learn from here ,when i try add ajax , its doesnt work at all here mmy code

this is the funtion for insert

    function tambah_data(){

    $data = array(
        'nama' => $this->input->post('nama'),


this is for model

function insert_mtk($data) {
    return $this->db->insert('master_matakuliah',$data);

this is y JQGRID

    url:'<?php echo base_url().'index.php/Welcome/lihat_data'?>',
    datatype: "json",
    colNames:['ID','NAMA','DESKRIPSI', 'USER ID', 'DATE CREATED'],
        {name:'id',index:'id', width:55, editable: false},
        {name:'nama',index:'nama', width:55, editable: true},
        {name:'deskripsi',index:'deskripsi', width:350, sortable:false, editable: true, edittype:"textarea"},   
        {name:'user_id',index:'user_id', width:300, editable: true},    
        {name:'created_time',index:'created_time', width:300, editable: true, unformat: pickDate},  
    loadonce: true,
    pager: '#pager2',
    sortname: 'id',
    viewrecords: true,
    sortorder: "desc",
    editable: true

this is my ajax ( but i stil dont know where to put ajax inside JQGrid or outside then making function)

    function AddPost(params) {
    var selr = $('#grid-table').jqGrid('getGridParam','selrow'); 
    var id = $('#grid-table').getCell(selr, 'id');

        type: "POST",
        url : '<?php echo base_url() ?>index.php/Welcome/tambah_data',//something is saved
        dataType: "JSON",

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *