I'm using jquery to call a webservice which returns a dataset with a couple of tables in it.
This was working ok until i needed to set up my webmethod to accept a parameter. I reflected this on the client side with
data: "{paramname:'" + paramval+ "'}",
I now get the following error when the webmethod returns. This happens regardless of whats being returned in the dataset
Error:{"Message":"A circular reference was detected while serializing an object of type \u0027System.Globalization.CultureInfo\u0027.","StackTrace":" at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)\r\n at ...etc
When the webmethod has no parameters the client side js looks the same as below except the data: line is removed.
function ClientWebService(paramval){
$.ajax({
type: "POST",
url: "WebService1.asmx/webmethodName",
data: "{paramname:'" + paramval+ "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
ParseResult(msg.d);
},
error: function(err) {
if (err.status == 200) {
ParseResult(err);
}
else { alert('Error:' + err.responseText + ' Status: ' + err.status); }
}
});
}
Edit: As per suggestion to change the request to
data: {paramname: paramval},
yields the following error.
Error:{"Message":"Invalid JSON primitive: paramval.","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.DeserializeT\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"} Status: 500