I have a controller class that retrieves data from the database and returns it within a function. I now need to call this function in JavaScript and store the data in variables for display on a page:
Here is an example of my code: 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);
}
}
}
The above code successfully retrieves the data. Now, I have a script file named myExp.js
where I intend to use this data. How can I achieve this?
Thank you.