How to get value from controller with jquery |
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 option ![]() }, 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 ! |
Messages In This Thread |
How to get value from controller with jquery - by keziaendhy - 06-27-2017, 08:05 AM
RE: How to get value from controller with jquery - by InsiteFX - 06-27-2017, 11:19 AM
RE: How to get value from controller with jquery - by PaulD - 06-27-2017, 11:57 AM
RE: How to get value from controller with jquery - by InsiteFX - 06-27-2017, 01:51 PM
RE: How to get value from controller with jquery - by rtenny - 06-28-2017, 02:39 AM
RE: How to get value from controller with jquery - by ciadvantage - 06-30-2017, 10:39 AM
|