我有一个 DoughnutChart 图表,我想根据保存在数据库中的颜色六进制代码更改其部分的颜色,我使用此 Ajax 方法通过调用返回 JSON Result 的操作方法来获取颜色字符串,
getcolors: function getcolors(name) {
return $.ajax({
url: "/api/ideas/getcolors",
data: { name: name },
type: "GET",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data, textStatus, jqXHR) {
// return data;
},
error: function (data) {
// return "Failed";
},
async: true
});
Run Code Online (Sandbox Code Playgroud)
但我没有收到字符串,而是在控制台窗口中收到了 Object {readyState: 1}
但是,我可以找到存储在 ResponseText 元素中的颜色值。我需要您帮助我如何将颜色值作为字符串获取。
编辑 :
为了让事情更清楚,我想调用 ajax 方法来接收颜色字符串,然后我将能够推送图表颜色数组。
getColorArray: function getColorArray(categories) {
var colors = [];
for (var i = 0; i < categories.length; i++) {
console.log(this.getcolors("Risk")); …
Run Code Online (Sandbox Code Playgroud) 问题已经更新,以便更好地解释我的问题,
我只有这个控制器,
[Authorize]
public class IdeaManagementController : Controller
{
private IIdeaManagementService _ideaManagementService;
private ITenantService _tenantService;
private ITagService _tagService;
private IEmployeeIdeaCategoryService _ideaManagementCategoryService;
private static PbdModule _modul = PbdModule.IdeaManagement;
IAuthorizationService _authorizationService;
public IdeaManagementController(
IIdeaManagementService ideaManagementService,
ITenantService tenantService,
ITagService tagService,
IAuthorizationService authorizationService,
IEmployeeIdeaCategoryService ideaManagementCategoryService)
{
_ideaManagementService = ideaManagementService;
_tenantService = tenantService;
_tagService = tagService;
_authorizationService = authorizationService;
_ideaManagementCategoryService = ideaManagementCategoryService;
}
public async Task<IActionResult> IdeaCoordinator()
{
if (!await _authorizationService.AuthorizeAsync(User, "IdeaManagement_Coordinator"))
{
return new ChallengeResult();
}
var ideas = _ideaManagementService.GetByIdeaCoordinator(_tenantService.GetCurrentTenantId());
return View(ideas);
}
} …
Run Code Online (Sandbox Code Playgroud) c# unit-testing xunit.net asp.net-core-mvc asp.net-core-identity