Alex Rivera | Logout

Json result wrapped in pre tag - how to get value of it

Asked 2011-09-26T18:22:58.383
9

This is first time that I work with json. I am trying to return Json from my action method:

public JsonResult Upload()
{
   ...
   return Json(new { foo = "sos....sos....sos..."});
}

But in result all I get is my message wrap in this "pre" tag. How to parse "foo" from this?

"<pre style="word-wrap: break-word; white-space: pre-wrap;">{"foo":"sos....sos....sos..."}</pre>"
Edit
Report

1 Answer

4

This returns the content of the first pre tag with the class "yourclass".

document.querySelector("pre.yourclass").innerHTML
answered 2011-09-26T18:36:16.337

Your Answer