【发布时间】:2013-06-26 07:12:33
【问题描述】:
我有一个控制器类,我从数据库中获取数据并在函数中返回,现在我想在 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 我需要在其中使用这些数据。我该怎么做?
谢谢
【问题讨论】:
标签: c# javascript .net ajax asp.net-mvc