Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>"
like image 627
1110 Avatar asked Sep 26 '11 18:09

1110


1 Answers

I think the reason you are receiving the data wrapped in a pre tag is because you are requesting the data as HTML and not plain text or json.

Try specifying the data type as json to stop the response being converted to HTML.

like image 61
jdavies Avatar answered Oct 05 '22 12:10

jdavies