json オブジェクトを返すコントローラーがあります。コントローラーをチェックしたところ、正常に動作しています。
これが私のコントローラーのサンプル結果です
{"CompliantCount":0,"NonCompliantCount":0,"StatusOfRiskItems":[{"Id":4,"Status":"Closed","Count":0},{"Id":1,"Status":"Open","Count":0},{"Id":2,"Status":"Mitigating Control Implemented","Count":0},{"Id":3,"Status":"Risk Accepted","Count":0}],"RiskLevelBreakdownOfOpenItems":[{"Id":0,"RiskLevel":"N/A","Count":0},{"Id":1,"RiskLevel":"Low","Count":0},{"Id":2,"RiskLevel":"Medium","Count":0},{"Id":3,"RiskLevel":"High","Count":0},{"Id":4,"RiskLevel":"Very High","Count":0}],"RiskLevelStatusPerDepartment":[],"CompliancePerDepartment":[],"CurrentRiskLevel":"N/A","ComplianceRating":NaN}
しかし、ajax で json を使用すると、null が返されます
function RiskRegisterReport(siteId, programId, departmentId, status, auditType, auditor, auditDate) {
var _data;
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8;",
url: hostpath + "/RiskRegister/RiskRegisterReport/",
dataType: "json",
async: false,
data: {
siteId: siteId,
programId: programId,
departmentId: departmentId,
statusId: status,
auditType: auditType,
auditor: auditor,
auditDate: auditDate
},
success: function (data) {
/// after getting the data
/// push the data.Compliant and data.NonCompiant to the array
_data = data;
}
});
return _data;
}