转义Json内容

I am using AJAX function to update a row. When users click on update button, I call an AJAX function which open a div which contains all the form fields. I have rendered a template and passed that as ajax response. However my form contain a textarea inside which html tags does get escaped e.g link would display like

<a href="http://example.com" rel="nofollow" target="_blank">http://example.com/</a>

I have used JSON.stringify, jQuery.parseJSON before populating div and twig's raw function on form filed but no success.

My form field looks like :

{{ form_widget(form.comments,{ 'value': obj.comments|raw}, {'attr':{'style':'width:'}}) }}

I believe, it has nothing to do with JSON as the template is triggered before encoding the content but I wanted to describe the whole scenario.

Controller

$content = $this->renderView("ex.html.twig", array('form'=>$form->createView()));
        return new Response(json_encode($content), 200, array("Content-Type" => "application/json"));

use JavaScript escape function after using JSON.stringify

function stringifyP(a) {
    return escape(JSON.stringify(a));
}

A simple textarea cannot display "HTML" content, so it is always going to show what you call "escaped" content, as it can only display plain text. You need to find an alternative to a textarea, like a wysiwyg editor like TinyMCE or a div with the contentEditable attribute.