Using an .net MVC2 app is generating a string of HTML code that be copy/pasted by my users to a 3rd party’s web app. In other words, i’m not looking to render the HTML – i want the string to be displayed verbatim.
I need to understand what JSON/jQuery properties have to be explicitly set so that my app’s string shows up as pure ascii – the HTML codes are displayed unaltered, unescaped, unrendered.
tx
JSON itself is just text (ASCII, UTF-8, or otherwise). HTML embedded within it has absolutely no special meaning.
The only reason the browser would ever render that text as HTML is if you inject it onto the page as such, perhaps using the
.html()function.If you want to inject it as text, try the
.text()function or, if you’re talking about atextareaor other form element,.val().You don’t need to make any changes to the ASP code or JSON; it’s purely a question of what you do with the content once you’ve got it.