I'm passing some string messages as Json object in view.
public ActionResult SomeAction(someObject object)
{
.....
.....
if (check1)
{
return Json(new { error = Resource.someMessage1},JsonRequestBehavior.AllowGet);
}
if(check2)
{
return Json(new { error = Resource.someMessage2}, JsonRequestBehavior.AllowGet);
}
//some stuffs
return Json(new {success = "success"}, JsonRequestBehavior.AllowGet);
}
I want to retrieve the messages passed from controller and alert from My view
in view I have some javascript
function done(data) {
alert("hello");
var message = JSON.parse(data);
alert(message);
if (message["error"] != undefined) {
alert(message["error"]);
} else {
//do some stuff
}
};
what I was expecting is if passed message from controller is type error then I would get alert with the message.
The line alert("hello"); but there is no alert after that.
I get error in console

Am I doing something wrong?
done()function.{"error":"somemessage"}. If no, I probably didn't understand what u meant, sorry. Quite new to this front end thing[object object]as alert