0

我有:

$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$this->render("voucher-list");

问题是,当我执行时:

$this->render("voucher-list");

它实际上将信息打印到屏幕上。我想将数据作为 HTML 字符串返回。这不起作用:

$htmlcontent = $this->render("voucher-list");

我将如何将此信息作为字符串返回?

4

1 回答 1

1

If you want to send the data into JSON format then you need to make the array of data and use the following code to send the data:

  $data = array(3,4,'test', 'my-name' => 3,4); //suppose this is your data
  $this->_helper->viewRenderer->setNoRender(true);
  $this->view->layout()->disableLayout(); 
  echo Zend_Json::encode($data);

And you will get the data in JSON format.

See this: Zend Framework JSON Output

于 2013-05-15T09:20:56.993 回答