This is a part of my controller,i need to pass the data in the variable $coinPacks into my view page
else {
$coinPacks=$packs->getPacks();
// print_r($coinPacks);
echo $this->_helper->json(array('error'=>array('error_code'=>300,'error_message'=>'No enough coins to do correction.','pack'=>$coinPacks)));
}
here is the view page part
alert(JSON.stringify(response.error));
// foreach($pack as $newpacks)
// {
answerContent = answerContent + '<p class="buy-coins" value="1" coins="100">200 $1</p><p>';
answerContent = answerContent + '<p class="buy-coins" value="3" coins="500">500 $3</p><p>';
answerContent = answerContent + '<p class="buy-coins" value="5" coins="1000">1000 $5</p><p>';
answerContent = answerContent + '<p class="buy-coins" value="15" coins="5000">5000 $15</p><p>';
// }
i need to get the values that passes from the view and use the value to make loop and display the corresponding value from the database.i really don't have much knowledge in json.please give me some advice.
am getting an alert like this
{"error":{"error_code":300,"error_message":"No enough coins to do correction.","pack":{}}}