我的ajax帖子,
function getuser() {
if (window.user == undefined) {
$.ajax({
type: "POST",
url: url, // value from view file(var url = "@Url.Action("getuser", "home")";)
data: { },
async: false,
cache: false,
success: function (result) {
window.user = result.data.user;
}
});
}
}
我的控制器,
[Authorize]
public class HomeController
{
[HttpPost]
public JsonResult GetUser()
{
return this.Json(new { data = GetUser() });
}
}
我也删除了async: false
。但是我的控制器方法没有触发。请纠正我错在哪里?