Problem with receiving data from Controller using .getJSON() and CodeIgniter?

Ur encoding it twice, not sure if json_encode deals with that or not but still $json should not be json_encode.

Up vote 0 down vote favorite share g+ share fb share tw.

I'm wondering why it doesn't work for me. I followed instructions from here: stackoverflow.com/questions/5418179/prob... but maybe I'm doing something wrong. I'm trying to make script that will populate the rest of the fields when user selects a value from select menu.

My jQuery script looks like this: $(document). Ready(function() { $('#selprod-1'). Change(function() { var id = $('#selprod-1 option:selected').val(); $.

Post( 'faktura/pobierzProdukt/'+id, function(data){ alert(data); $('#pkwiu'). Val(data. Product_pkwiu); $('#netto').

Val(data. Product_netto); $('#vat'). Val(data.

Product_vat); $('#brutto'). Val(data. Product_brutto); $('#jedn').

Val(data. Product_jedn); }, 'json' ); }); }); My HTML form looks like this: 1 'pkwiu','class'=>'short','readonly'=>'readonly'));? > 'netto','class'=>'short','id'=>'netto','readonly'=>'readonly'));?

> 'vat','class'=>'mini','id'=>'vat','readonly'=>'readonly'));? > 'brutto','class'=>'short','id'=>'brutto','readonly'=>'readonly'));? > 'jedn','class'=>'mini','id'=>'jedn','readonly'=>'readonly'));?

> 'ilosc','class'=>'short','id'=>'ilosc'));? > 'knetto','class'=>'short','id'=>'knetto','readonly'=>'readonly'));? > 'kvat','class'=>'short','id'=>'kvat','readonly'=>'readonly'));?

> 'kbrutto','class'=>'short','id'=>'kbrutto','readonly'=>'readonly'));? > My controller function (which works) looks like this: public function pobierzProdukt($id) { $json = json_encode($this->Faktura_model->getProduct($id)); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 2027 05:00:00 GMT'); header('Content-type: application/json'); echo $json; } My model function looks like this: public function getProduct($id) { $q = 'SELECT product_vat, product_netto, product_brutto, product_jedn FROM products WHERE product_id="'. $id.

'"'; $w = $this->db->query($q); return json_encode($w->row_array()); } jquery ajax codeigniter getjson link|improve this question edited May 16 '11 at 12:32 asked May 16 '11 at 12:25sunpietro578 33% accept rate.

Ur encoding it twice, not sure if json_encode deals with that or not but still $json should not be json_encode – Val May 16 '11 at 12:43 Thanks a lot. I didn't notice it before. – sunpietro May 16 '11 at 13:42 did that fix it?

– Val May 16 '11 at 14:39 yes, thanks a lot – sunpietro May 17 '11 at 6:46 You can mark the answer below lol :) – Val May 17 '11 at 8:51.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions