I have a simple web method and ajax call and continue to recieve an error that saying that it can't convert a string to an IDictionary object???
Here is the ajax call:
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) { . . . .
Here is the webMethod:
<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
Here is what I see from FireBug:
Response Headers
Server: Microsoft-IIS/5.1
Date: Thu, 09 Apr 2009 21:43:59 GMT
jsonerror:true
Cache-Control:private
Content-Type:application/json; charset=utf-8
Content-Length:1331
POST: "{"ID":"4"}"
RESPONSE:
{"Message":"Cannot convert object of type u0027System.Stringu0027 to type u0027System.Collections
.Generic.IDictionary`2[System.String,System.Object]u0027","StackTrace":" at System.Web.Script.Serialization
.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean
throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain
(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject
)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToType(Object o, Type type, JavaScriptSerializer
serializer)
at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer
serializer, String input, Type type, Int32 depthLimit)
at System.Web.Script.Serialization.JavaScriptSerializer
.Deserialize[T](String input)
at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest
(HttpContext context, JavaScriptSerializer serializer)
at System.Web.Script.Services.RestHandler
.GetRawParams(WebServiceMethodData methodData, HttpContext context)
at System.Web.Script.Services
.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType"
:"System.InvalidOperationException"}
Anyone have any ideas about this? Thanks!!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…