0

If you do this in MVC:

var jsonData = 
    new { myimage = 
        "<img alt=\"\" src=\"/Content/images/ShowFPots.png\" />" };

return Json(jsonData);

You get this as a value

"\u003cimg alt=\"\" src=\"/Content/images/ShowFPots.png\" /\u003e"

How do I get this as a value, or will the <> interpret correctly when I add them to the innerHtml??

"<img alt=\"\" src=\"/Content/images/ShowFPots.png\" />"

1 Answer 1

4

that is correct javascript, unicode encoding. It'll be fine inserting it into html/DOM

https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Unicode

Sign up to request clarification or add additional context in comments.

2 Comments

<img alt="" src="/Content/images/ShowFPots.png"> is what inserts. The <> are correct but it is missing the / before the end tag (/>). Odd.
That is most likely the browser/DOM manipulating the html, but you can see the / at the end of your string in your question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.