Welcome Guest, Not a member yet? Register   Sign In
How to get value from controller with jquery

I always do things like get result from query as array such as result_array() for multi dimension or single array like row_array() then simply
For example , in your case, I would do this
$res= $this->barang_model->get_autocomplete($id); //assume you get row_array as return
echo json_encode($res);
OR I usually wrap it up with success and message, data like this:
echo json_encode(array('success'=>1, 'message'=>'anything you want to read', 'data'=>$res));

My frontend at ajax,  I often using

//you can check result data here
},'json')    //make sure you have 'json' to indicate that you need json as content type !
//I often do this here
   console.log(JSON.stringify(result.data));//show all your json string as data
   console.log(JSON.stringify(result.data.stock)); //will show your stock value !
//action for failures so on

Messages In This Thread
RE: How to get value from controller with jquery - by ciadvantage - 06-30-2017, 10:39 AM

Theme © iAndrew 2016 - Forum software by © MyBB