如何使用 JsAction 获取 Json 值?如何获得名字?我想显示 Json 值的任何值。
控制器:
[JsAction()]
[HttpGet]
public JsonResult GetStudent(int a)
{
Student st = new Student() { firstName = "yusuf", lastName = "karatoprak", SumHere = 5 };
return Json(st, JsonRequestBehavior.AllowGet);
}
看法:
$(document).ready(function () {
JsActions.Home.MyTestMethod(1, 2).then(function (data) { alert(data); });
JsActions.Home.MyTestMethod2(4, 5).then(function (data) { alert(data); });
JsActions.Home.Yusuf(67, 9).then(function (data) { alert(data.toString()); });
var ret = JsActions.Home.GetStudent(6);
alert(ret.firstName);
console.log(ret.firstName);
})
但我无法访问名字。我看到一些代码形式的codeplex: