In jQuery, I am returning HTML in a JSON result, what do I have to escape?

前端 未结 6 902
情歌与酒
情歌与酒 2020-12-15 13:07

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,

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 13:44

    An alternative solution would be to simply return the HTML and use jQuery's load():

    $('#someDiv').load('servershtml.html');
    

    To do it your way though, you would need only to escape double quotes and backslashes.

    The specification is very readable and short.

提交回复
热议问题