My controller has a method that returns Json data.
[HttpPost]
public JsonResult CompanyChart()
{
var data = db.adusers;
var selectUsers = from s in data where (s.Company != null) select s;
int fenixPlus = (from fP in data where (fP.Company == "ООО \"Феникс+\"") select fP).Count();
int fenixPresent = (from fP in data where (fP.Company == "ООО \"Феникс-Презент\"") select fP).Count();
var dataObj = new object[]
{
new object[] {"Компания","Количество"},
new object[] { "ООО \"Феникс+\"", fenixPlus},
new object[] { "ООО \"Феникс-Презент\"", fenixPresent}
};
return Json(dataObj, JsonRequestBehavior.AllowGet);
}
The Json returned by the method looks like this:
[["Компания","Количество"],["ООО \"Феникс+\"",53],["ООО \"Феникс-Презент\"",42]]
In my view, I have a jQuery post request:
$.ajax({
url: '@Url.Action("CompanyChart", "Users")',
type: 'post',
dataType: "json",
success: function (data) {
drawChart(data);
}
});
However, when I try to draw a Google pie chart, it doesn't work and there is an error in the console:
Uncaught SyntaxError: Unexpected token К in JSON at position 0
I am unsure why my code is not working. Can anyone help me understand why?