Php 使用symfony 1.4构造JSON对象,其中包含一个包含html内容的字段
我在这里看到了一些关于几乎相同事情的问题,但是,在遵循他们的建议后,我不断得到相同的行为 我在我的操作中构建json对象,如下所示:Php 使用symfony 1.4构造JSON对象,其中包含一个包含html内容的字段,php,jquery,symfony-1.4,json,Php,Jquery,Symfony 1.4,Json,我在这里看到了一些关于几乎相同事情的问题,但是,在遵循他们的建议后,我不断得到相同的行为 我在我的操作中构建json对象,如下所示: return $this->renderText(json_encode(array( 'html' => addslashes($this->renderPartial('global/formWrapper', array( 'f
return $this->renderText(json_encode(array(
'html' => addslashes($this->renderPartial('global/formWrapper',
array(
'form' => $nareas,
'url' => $this->generateUrl('new_promo_step2'),
'cancelUrl' => 'new_promo',
))),
'error' => true)));
我得到的答复如下:
<html>
The html content which is supposed to be in the "html" property of my json
object...
</html>{"html":"None","error":true}
求你了!任何帮助都将不胜感激
谢谢 要从操作中渲染部分,需要将部分作为包含加载,并使用getPartial将其检索到renderText调用中
sfLoader::loadHelpers('Partial');
return $this->renderText(json_encode(array(
'html' => addslashes(getPartial('global/formWrapper',
array(
'form' => $nareas,
'url' => $this->generateUrl('new_promo_step2'),
'cancelUrl' => 'new_promo',
))),
'error' => true)));
sfLoader::loadHelpers('Partial');
return $this->renderText(json_encode(array(
'html' => addslashes(getPartial('global/formWrapper',
array(
'form' => $nareas,
'url' => $this->generateUrl('new_promo_step2'),
'cancelUrl' => 'new_promo',
))),
'error' => true)));