我正在使用以下Kendo UI Grid来使用下面的ASMX服务。我已经证实,该服务emmitting JSON如果我使用一个标准的jQuery AJAX方法,但如果我尝试用剑道电网消耗它,然后我得到这个作为响应:带有ASMX服务的Kendo UI Grid:返回XML而不是JSON
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfEmployeeCountByTypeModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:nil="true" xmlns="http://tempuri.org/" />
$("#grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
type: "POST",
dataType: "json",
url: "HRDashboardService.asmx/GetEmployeeCountByType",
},
contentType: "application/json; charset=utf-8"
},
schema: {
data: "d",
model: {
fields: {
FY: { type: "string" },
Month: { type: "string" },
AreaName: { type: "string" },
PFCName: { type: "string" },
OnRoll: { type: "number" }
}
}
}
},
groupable: false,
sortable: true,
pageable: {
refresh: true,
pageSizes: true
},
columns: [{
field: "FY",
width: 20,
title: "FY"
},
{
field: "Month",
width: 20,
title: "Month"
},
{
width: 20,
field: "AreaName",
title: "Area Name"
},
{
width: 20,
field: "PFCName",
title: "PFC Name"
},
{
field: "EmployeeType",
width: 40,
title: "Employee Type"
},
{
width: 20,
field: "OnRolls",
title: "OnRolls"
}]
});
这里是我的ASMX服务:
<WebMethod()> _
Public Function GetEmployeeCountByType() As List(Of EmployeeCountByTypeModel)
Dim results As List(Of EmployeeCountByTypeModel) = Nothing
Try
results = (From r In DbContext.SprocEmployeeCountByType
Select New EmployeeCountByTypeModel With { _
.AreaCode = r.AreaCode, _
.FY = r.FY, _
.AreaName = r.AreaName, _
.EmployeeType = r.EmployeeType, _
.Month = r.Month, _
.OnRoll = r.OnRoll, _
.PFCCode = r.PFCCode, _
.PFCName = r.PFCName _
}).ToList()
Catch ex As Exception
End Try
Return results
End Function
是的,我已经证实,它使用的是POST不是GET。 – Asmussen