我有一個控制器類,我從數據庫中獲取數據並將其返回給一個函數,現在我想在js中調用此函數並將數據設置爲顯示在頁面中的變量:在visual studio中調用JavaScript的類
我的代碼如下所示: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
,我需要在其中使用這些數據。我怎樣才能做到這一點?
感謝