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

Controller :
function auto_barang(){
$id=$this->input->post('id');
$res= $this->barang_model->get_autocomplete($id);
//foreach ($res as $rows){
// $hasil['stock']=$rows['stock'];
//}
//$this->output->set_content_type('application/json');
$this->output->set_output(json_encode($res));
}

Script :
<script>
$(document).ready(function(){
    $("#barang").change(function(){
        $.post("<?php echo base_url()."index.php/pembelian/auto_barang"; ?>",
        {
            id:$("#barang optionConfusedelected").val()
        }, function(data){
            alert(data);
        });        
});
</script>

Output :
[{"id":"2","nama":"Lenovo ideapad 200","harga_beli":"2000000","harga_jual":"2500000","stock":"5"}]

How to if I just want to take stock value? Thank you !
Reply


Messages In This Thread
How to get value from controller with jquery - by keziaendhy - 06-27-2017, 08:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB