In my Ajax request (using jQuery) I am returning a JSON response.
So json.Html will have a string of HTML I want to append inside a div.
On the server side, do I have to escape the HTML at all?
In my MVC action, I am returning:
return Content("{html: ???????}, "application/json");
Best Solution
An alternative solution would be to simply return the HTML and use jQuery's
load()
:To do it your way though, you would need only to escape double quotes and backslashes.
The specification is very readable and short.