0
我在這裏看到一些關於幾乎相同的事情的問題,但是,在遵循他們的建議之後,我一直得到相同的行爲。用symfony 1.4構造JSON對象,並用html內容字段
我構建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請求,我給自己定具體的數據類型爲「JSON」(當然,我得到一個意外的字符錯誤),併爲「文本」(我沒有錯誤,但不斷收到畸形的JSON )
我試過使用addslashes()
(如例),並沒有這個功能;嘗試使用ESC_RAW
symfony選項,並得到相同的。
我期待得到的東西是這樣的:
{"html":"<html>Html content</html>","error":true}
請!任何幫助將不勝感激!
謝謝!