I have this sample HTML, that needs to be passed through ajax to a server side function, replace some variables and then passed back to be displayed AS HTML.
But it gets encoded, and html sanitised so many times I get confused!
The html is being passed in this form:
"<style type="text/css">* {↵ margin-top: 0px;↵ …↵ etc
in the BackEnd it appears like this: (RAW- obviously url encoded)
%22%3Cstyle+type%3D%5C%22text%2Fcss%5C%22%3E*+%7B%5Cn++++margin-top%3A+0px%3B%5Cn++++margin-
then its urlDecoded:
"<style type=\"text/css\">* {\n margin-top: 0px;\n margin-bottom: 0px;\n padding: 0px;\n border: none;\n line-height: normal;\n outline: none;\n
Then its sent back to the ajax and received from the ajax like this:
"'"<style type=\\"text/css\\">* {\\n margin-top: 0px;\\n margin-bottom: 0px;\\n padding: 0px;\\n border: none;\\n line-height: normal;\\n outline: none;\\n list-
What do I have to do, so that I can take this string that Ajax receives and display it normal as HTML within a div? why are there so many \n and \t? Even when I parsed the HTML it just replaced them with HTML special characters but still wasn't rendered by the browser.
Ajax:
$.ajax({
type: "POST",
async: false,
url: "url",
data: {htmlTemplate: JSON.stringify(data.html)},
success: function (Data) {
ajaxOutput = Data;
},
error: function (err) {
}
});