我的网络服务方法如下:
<WebMethod()> _
Public Function TravelMeansList(ByVal prefix As String) As List(Of HRM_travellingMeans)
Dim ctx As New HRMEntities
Dim query = From c In ctx.HRM_travellingMeans Where c.name.ToUpper.StartsWith(prefix) Select c
If query.Count > 0 Then
Return query.ToList()
Else
Return Nothing
End If
End Function
我的脚本如下
<script type="text/javascript">
$(document).ready(function () {
$("#<%=travelmeansTextBox.ClientID %>").autocomplete({
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("../../services/ApplicationService.asmx/TravelMeansList") %>',
data: "{ 'prefix': '" + request.term + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) { return data; },
success: function (data) {
response($.map(data.d, function (item) {
return Json({
value: item.name
})
}))
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
},
select: function (e, i) {
},
minLength: 1
});
});
</script>
我的问题是,每当我尝试在文本框中输入任何字母时,都会出现此错误
在 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 深度、Hashtable objectsInUse、SerializationFormat serializationFormat、MemberInfo currentMember)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)\r\ n 在 System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)\r\n 在 System.Web.Script.Serialization.JavaScriptSerializer。SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)\r\n 在 System.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable ......序列化枚举......序列化枚举......
我究竟做错了什么。