我收到此错误,我不知道如何通过它。我正在尝试执行ajax调用来填充我的数据存储。错误是:
当我这样做时,没有调用Parsererror'function':
var customStore = new DevExpress.data.CustomStore({
load: function () {
return $.ajax({
url: 'URL/Service/GetCustomers?callback=?fnsuccesscallback',
crossOrigin: true,
crossDomain: true,
jsonp: true,
type: 'GET',
dataType: 'jsonp',
contentType: "application/json; charset=utf-8",
jsonpCallback: 'fnsuccesscallback',
async: false,
success: function (res) {
console.log("success");
res = JSON.parse(res);
console.log("data _" + res);
},
error: function (xhr, status, error) {
console.log(xhr);
console.log(status);
console.log(error);
}
});
}
});
var fnsuccesscallback = function (data) {
alert(data);
};
var gridDataSourceConfiguration = {
store: customStore
};
此功能的我的服务代码是:
Function GetCustomers() As Stream Implements IService.GetCustomers
Try
Dim Cust As List(Of Customers) = New List(Of Customers)
Dim SQLSTR As String = ""
SQLSTR = "Select Code, Name, ID FROM Table"
Dim ErrorMessage As String = ""
ErrorMessage = Obj.OpenConnection(SQLServer, UmbrellaDatabase, UserCode, UserPassword)
If ErrorMessage <> "" Then
System.Diagnostics.EventLog.WriteEntry("APP", ErrorMessage, EventLogEntryType.Error)
WebOperationContext.Current.OutgoingResponse.StatusCode = 501
WebOperationContext.Current.OutgoingResponse.StatusDescription = ErrorMessage
Return Nothing
Else
Dim CustomerDetails As DataSet
CustomerDetails = tObj.GetDataSQL(SQLSTR)
If Not CustomerDetails Is Nothing Then
CustomerDetails.DataSetName = "Companies"
CustomerDetails.Tables(0).TableName = "Companies"
Dim CustomerTable As DataTable
Dim CustomerRow As DataRow
If CustomerDetails.Tables.Count > 0 Then
CustomerTable = CustomerDetails.Tables(0)
If CustomerTable.Rows.Count > 0 Then
Dim i As Integer
For i = 0 To CustomerTable.Rows.Count - 1
CustomerRow = CustomerTable.Rows(i)
Dim CC As New Customers
CC.Code = CustomerRow.Item("Code")
CC.Name = CustomerRow.Item("Name")
CC.InternalID = CustomerRow.Item("InternalID")
Cust.Add(CC)
Next i
' Serialize the results as JSON
Dim serializer As DataContractJsonSerializer = New DataContractJsonSerializer(Cust.GetType())
Dim Stream As MemoryStream = New MemoryStream
serializer.WriteObject(Stream, Cust)
' Return the results serialized as JSON
Dim json As String = Encoding.Default.GetString(Stream.ToArray())
Return New MemoryStream(Encoding.UTF8.GetBytes(json))
Obj.CloseConnection()
WebOperationContext.Current.OutgoingResponse.StatusCode = 200
WebOperationContext.Current.OutgoingResponse.StatusDescription = "OK"
End If
End If
Else
System.Diagnostics.EventLog.WriteEntry("APP", ErrorMessage, EventLogEntryType.Error)
WebOperationContext.Current.OutgoingResponse.StatusCode = 501
WebOperationContext.Current.OutgoingResponse.StatusDescription = ErrorMessage
Cust = Nothing
Return Nothing
End If
End If
Catch ex As Exception
System.Diagnostics.EventLog.WriteEntry("Umbrella Mobile Service", ex.Message, EventLogEntryType.Error)
WebOperationContext.Current.OutgoingResponse.StatusCode = 501
WebOperationContext.Current.OutgoingResponse.StatusDescription = ex.Message
Return Nothing
End Try
Dispose()
End Function
为了发送正确的回调,我的JSON输出应如何在我的服务中显示?为了不显示此错误,我该怎么做?