Well, perhaps the best solution is to use JSON serialization.
public ActionResult DoSomething(string parameter)
{
bool result = true;
return Json(new ActionInfo()
{
Success =result,
});
}
ActionInfo is just a class with one property, boolean Success.Then, jquery ajax call:
$.ajax({
type: "POST",
url: "YourController/DoSomething?parameter=pValue",
data: {},
dataType: "json",
success: function(actionInfo) {
alert(actionInfo.Success);
}});
Hope this helps.
source
share