我正在尝试使用ajax获取请求将数据绑定到jquery数据表,但是在ajax获取请求的成功功能中,由于未定义Refrence错误数据,我遇到了错误
下面我提供了我尝试过的细节
下面是控制器代码:-
public ActionResult BindBrand()
{
return View();
}
[HttpGet]
public JsonResult GetBrand()
{
var finalResult = Common.GetProductBrand("1001");
var JSONString = JsonConvert.SerializeObject(finalResult);
var brandList = JsonConvert.DeserializeObject<IEnumerable<GlobalCodes>>(JSONString);
return Json(brandList, JsonRequestBehavior.AllowGet);
}
及以下是Mvc视图中的代码
<script>
$(document).ready(function () {
debugger;
$.ajax({
type: "GET",
url: '@Url.Action("GetBrand", "Product")',
//dataType: "json",
//contentType: "application/json; charset=utf-8",
success: function (response) {
debugger;
var a = response.brandList;
}
});
});
function BindBrand(msg) {
debugger;
var properties = {
bProcessing: true,
bDestroy: true,
bSort: true,
data: msg,
aoColumns: [
{ mData: 'GlobalCodeName' },
{
mData: "",
bSortable: true,
mRender: function (cellvalue, options, rowObject) {
//return "<i class=\"fa fa-pencil-square-o\" aria-hidden=\"true\" name=\"id_'" + rowObject.GlobalCodeID + "'\" title=\"Update\" onclick=\"UpdateBrand('" + rowObject.Inv_MainID + "')\"></i><i class=far fa-check-square></i>";
return '<i id="DocumentsTemplateID' + rowObject.GlobalCodeID + '" onclick="EditDocumentDetail1(' + rowObject.GlobalCodeID + ');" class="fa fa-pencil-square-o" title="Edit Document"></i> <i onclick="SaveCheckboxvalue();" class="far fa-check-square"></i> ';
}
}
]
};
var table = $('#tblBrand').DataTable(properties);
}
</script>
我希望在ajax成功函数上获得请求时,我应该获取brandlist返回的json数据的列表,但是由于未定义Refrence错误数据,我面临着错误