Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing parameter to WebMethod with jQuery Ajax
    text
    copied!<p>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???</p> <p>Here is the ajax call:</p> <pre><code>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) { . . . . </code></pre> <p>Here is the webMethod:</p> <pre><code>&lt;WebMethod()&gt; _ 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 </code></pre> <p>Here is what I see from FireBug:</p> <p>Response Headers<br> Server: Microsoft-IIS/5.1<br> Date: Thu, 09 Apr 2009 21:43:59 GMT<br> jsonerror:true<br> Cache-Control:private<br> Content-Type:application/json; charset=utf-8<br> Content-Length:1331 </p> <p>POST: "{\"ID\":\"4\"}"</p> <p>RESPONSE: </p> <p>{"Message":"Cannot convert object of type \u0027System.String\u0027 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&amp; convertedObject)\r\n at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain (Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object&amp; convertedObject )\r\n at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToType(Object o, Type type, JavaScriptSerializer serializer)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Serialization.JavaScriptSerializer .Deserialize[T](String input)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest (HttpContext context, JavaScriptSerializer serializer)\r\n at System.Web.Script.Services.RestHandler .GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services .RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType" :"System.InvalidOperationException"}</p> <p>Anyone have any ideas about this? Thanks!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload