Hi Maulkye,

You set the application/json in the client call, but it is the
response from the server that should send this info. Is it the case?
Next, It seems that the JSON is not very well formatted, asOK is not a
good JSON value, try a good JSON ?

And my last remark is that it seems to be a server side problem ?? not
a real PROTOTYPE problem

--
david.


On Sep 4, 2:31 am, Maulkye <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I keep getting this error message (Invalid JSON primitive) when I try
> to call an Ajax.Request with the 'applicatio/json' content type.  I've
> tried formatting the parameters in a variety of ways, but no luck.
> Can anyone help?
>
> Here's what I have:
>
> CLIENT:
>             new Ajax.Request("/myService.asmx/GetComplexData",{
>                 onSuccess: onSuccess,
>                 onFailure: onFailure,
>                 method:"post",
>                 contentType:"application/json; charset=utf-8",
>                 parameters: {s: 'bob'}
>             });
>
> SERVER:
>
>         [WebMethod]
>         public string GetComplexData(string s)
>         {
>             return s;
>         }
>
> Note that other calls are working.  If I remove the content type, this
> woks ok, but it just populates the string parameter with the value of
> "s" from the client.  Additionally, I tried this on the server, but to
> no avail:
>
>         [WebMethod]
>         public string GetComplexData(object s)
>         {
>             return "ok";
>         }
>
> It seems like there's some way I'm supposed to format the parameters
> to make MS.NET happy, but I can't figure out how it is.  The server
> can obviously handle it, because if I use their big fat client library
> it sends json objects over and puts them into a dictionary object
> without a hitch.
>
> If anyone can offer some suggestions of even point in the right
> direction, I would be most appreciative.
>
> Thanks,
> -M
>
> Full Error Message:
> -----------------------------
> {"Message":"Invalid JSON primitive: s.","StackTrace":" at
> System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()
> \r\n at
> System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32
> depth)\r\n at
> System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String
> input, Int32 depthLimit, 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.ArgumentException"}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to