Ajax.BeginForm
calls an action and then returns JSON.
How do I access JSON object in my OnComplete
js function?
so my Ajax.BeginForm<
I bumped into this question looking for the answer to do the same thing in ASP.NET MVC 4, and none of the above worked, so for anyone looking for the answer, the data is already encoded from json when you recive it in your js function
public ActionResult Something()
{
return Json(new { result = 0, message = "Testing" });
}
...
new AjaxOptions { HttpMethod = "POST", OnSuccess= "something" }
...
function something(data) {
switch(data.result)
{
case 1:
alert(data.result)
break;
case 0:
alert(data.result)
break;
case -1:
alert(data.result)
break;
default:
alert(data.message);
}
}
This doesn't work with OnComplete I assuame it doesn't have paramtars to recive data.