【发布时间】:2012-01-05 17:30:54
【问题描述】:
我在这里看到了一些关于几乎相同的问题的问题,但是,在遵循他们的建议后,我一直得到相同的行为。
我正在按如下方式在我的操作中构造 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}
以及带有Content-Type:text/html; charset=utf-8 的标题。
在我的 jQuery ajax 请求中,我将 dataType 设置为“json”(当然,我会遇到意外的字符错误)和“text”(我没有收到任何错误,但会不断收到格式错误的 json)
我尝试过使用addslashes()(如示例中所示),但没有此功能;尝试使用ESC_RAW symfony 选项,结果相同。
我希望得到这样的东西:
{"html":"<html>Html content</html>","error":true}
请!任何帮助将不胜感激!
谢谢!
【问题讨论】:
标签: php jquery symfony-1.4 json