fn:Enkhbilguun Erdenetsogt
n:Erdenetsogt;Enkhbilguun
email;internet:enkhbilguun@beregu.com
tel;cell:99113638
x-mozilla-html:TRUE
version:2.1
end:vcard
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
没有评论:
发表评论