Question

I am intentionally making error i.e. using one of the coulmn's name wrong to learn how to handle the error with ajax call with codeigniter.

Last Comment in controller function at the end is my question/problem

My AJX Code is following. I am using ajaxform plugin. It shows me all response from controller perfectly but problem is only

I am unable to get response from model in controller while using ajax call that is little weird

$('#myForm').ajaxForm
({
    success: function(responseText)
    {
        if(responseText != "1")         
            $('#feedback').html(responseText);          
    }
});

Following is snapshot of exact error which i can see in console but unable to get in controller and hence in view. It describes complete error i.e unknown column in given query, but i captured only upper portion.

enter image description here

My model function is below

public function updateItem($id, $data, $tbl)
{
    $this->db->where('id', $id);
    $r = $this->db->update($tbl, $data);
    if($r)
        return $r;
    else
    {
        $r = $this->db->_error_message();
        return  $r;
    }
}

My controller function code

public function upadteme()
{
    $r = $this->ajax_model->updateItem($uid, $data, 'users');
    echo $r." -- "; // Unable to get this echo working 
    //when using ajaxcall (calling controller through ajax) otherwise fine
}
Was it helpful?

Solution

It looks like the class will not populate _error_message if db_debug is on which it appears to be by default.

In config/database.php, set

$db['default']['db_debug'] = FALSE;

and try again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top