我有一个控制器类,我从数据库中获取数据并在函数中返回它,现在我想在 js 中调用此函数并将数据设置为变量以显示在页面中:
我的代码看起来像:exampleController.cs
namespace iSee.WebApiHse.Controllers
{
public class expController : StandardController
{
public expController(
first myService,
ISystemSettings systemSettings,
IService myExpService)
{
_myService = MyService;
_systemSettings = systemSettings;
_myExpService = myExpService;
}
// GET data
public ActionResult Myexample(int id)
{
var elementIds = _systemSettings.ExpIds;
var myElements = CacheService.AllVisibleElements
.Where(x => elementIds.Contains(x.Id)).ToList();
var container = _kpiContainerService.Find(id);
var result = _myService.MonthByContainer(myElements, container);
return AsJson(result);
}
}
}
这有效,我得到了数据。现在我myExp.js
知道我需要在其中使用这些数据。我怎样才能做到这一点?
谢谢