tags:

views:

618

answers:

1

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\" />"
+3  A: 

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

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