我有一个简单的web方法和ajax调用,并继续收到一个错误,说它无法将字符串转换为IDictionary对象?
这是ajax调用:
var params = '{"ID":"' + rowid + '"}';
$.ajax({
url: 'EDI.asmx/GetPartnerDetails',
type: "POST",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(params),
dataType: "json", //not json . let me try to parse
success: function(msg, st) { . . . .
这是webMethod:
_
Public Function GetPartnerDetails(ByVal ID As String) As String
'Dim objParam As IDictionary = CType(JsonConvert.DeserializeObject(ID), IDictionary)
'Dim rowID As String = objParam("ID")
Dim objController As New HealthComp.BLL.X12Partners.TradingPartnersController
Dim objInfo As TradingPartnersInfo = objController.FetchByPartnerID(Int32.Parse(ID))
Return JsonConvert.SerializeObject(objInfo)
End Function
这是我从FireBug中看到的内容:
响应标头
服务器:Microsoft-IIS / 5.1
日期:2009年4月9日,星期四,格林尼治标准时间
jsonerror:true
缓存控制:私有
内容类型:application / json; charset = utf-8
内容长度:1331
POST:“ {\” ID \“:\” 4 \“}”
响应:
{“消息”:“无法在系统上将类型为\ u0027System.String \ u0027的对象转换为类型为\
u0027System.Collections .Generic.IDictionary`2 [System.String,System.Object] \
u0027“,” StackTrace“:”。 Web.Script.Serialization
.ObjectConverter.ConvertObjectToTypeInternal(Object o,Type
type,JavaScriptSerializer序列化器,布尔throwOnError,Object&ConvertedObject)\ r \
n位于System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object
o,Type
type,JavaScriptSerializer序列化器,System.Web.Script.Serialization.ObjectConverter.ConvertObjectToType(对象o,类型类型,JavaScriptSerializer序列化器)的布尔型throwOnError,Object&convertObject)\
r \ n,System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(
JavaScriptSerializer序列化器,字符串输入,类型类型,Int32 depthLimit)\ r \
n在System.Web.Script.Serialization.JavaScriptSerializer .Deserialize
[T](字符串输入)\ r \
n在System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext上下文,JavaScriptSerializer序列化器)\在System.Web.Script.Services.RestHandler
.GetRawParams(WebServiceMethodData methodData,HttpContext上下文)处为r \
n,在System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext上下文,WebServiceMethodData
methodData)处为r \ n“,” ExceptionType“ :“
System.InvalidOperationException”}GetRawParams(WebServiceMethodData
methodData,HttpContext上下文)\ r \ n位于System.Web.Script.Services
.RestHandler.ExecuteWebServiceCall(HttpContext上下文,WebServiceMethodData
methodData)“,” ExceptionType“:”
System.InvalidOperationException“}GetRawParams(WebServiceMethodData
methodData,HttpContext上下文)\ r \ n位于System.Web.Script.Services
.RestHandler.ExecuteWebServiceCall(HttpContext上下文,WebServiceMethodData
methodData)“,” ExceptionType“:” System.InvalidOperationException“}
有人对此有任何想法吗?谢谢!!