Hello,

I wanted to print json formatted response, which is passed from controller passing to a view script.
The response, which is catched with firebug is:

|{"ai80":"1050","ai92":"1100","diesel":"1300"}|


But I can't see any of those values on my browser. Please advice me what I made wrong.



In the controller:
=============
$fuels = new BEREGU_FuelsDbTable();
$result = $fuels->fetchAll();

foreach ($result as $fuel){
           switch ($fuel->id) {
               case '2':
                   $ai80 = $fuel->price;
               break;
case '3':
                   $ai92 = $fuel->price;
               break;
case '6':
                   $diesel = $fuel->price;
               break;
           }
       }

$item = array();
$item['ai80'] = $ai80;
$item['ai92'] = $ai92;
$item['diesel'] = $diesel;
echo Zend_Json_Encoder::encode($item);
///////////////////////////////

In the view script
=============
function getPriceJson(volume)
   {
       $.post(
       "/async/getprice",
       {
           "volume" :    volume
       },
function(response)
       {
           $("#ai92").append("<a href='#'>"+response.diesel+"</a>");
           $("#ai80").append(response.ai80);
           $("#diesel").append(response.diesel);
       });
   }
//////////////////////////////////////




Sincerely,
Enkhbilguun Erdenetsogt

<<attachment: enkhbilguun.vcf>>

Reply via email to