2012-05-11 7 views
0

私はビューという変数をStudentと定義します。私の見解では、StudentオブジェクトをJSONとしてどのように表示するのですか?私preview.phtmlビューでZend Framework 1.11でJSON形式のApplication_Modelを返す方法

public function previewAction() 
{ 
    // ... 
    $this->view->student = $student; 
} 

、私は次のようしている:PHPタグの周り

<script> 
    // this doesn't return the Application_Model as a JSON object in the html  
    var studentData = <?php echo Zend_Json::encode($this->student); ?>; 
</script> 
+2

このリターンを何? – skafandri

答えて

1

入れ相場

<script> 
    // this doesn't return the Application_Model as a JSON object in the html  
    var studentData = "<?php echo Zend_Json::encode($this->student); ?>"; 
</script> 
+0

これは、jpオブジェクト表記ではなく、JavaScript文字列としてphpによって生成されたjson結果を返します。 –

関連する問題