Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用symfony 1.4构造JSON对象,其中包含一个包含html内容的字段_Php_Jquery_Symfony 1.4_Json - Fatal编程技术网

Php 使用symfony 1.4构造JSON对象,其中包含一个包含html内容的字段

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

我在这里看到了一些关于几乎相同事情的问题,但是,在遵循他们的建议后,我不断得到相同的行为

我在我的操作中构建json对象,如下所示:

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)));