I am using jquery to call a web service that returns a dataset with multiple tables in it.
This worked fine until I needed to configure my web method to accept the parameter. I reflected this on the client side with
data: "{paramname:'" + paramval+ "'}",
Now I get the following error when returning a web method. This happens regardless of what is returned in the dataset.
Error: {"Message": "A circular reference was found while serializing an object of type \ u0027System.Globalization.CultureInfo \"., "StackTrace": "at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal (Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat) \ r \ n in ... etc.
If the web method has no parameters, the client js side looks the same as below, except for the data row: the row is deleted.
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 requested, change the request to
data: {paramname: paramval},
produces the following error.
Error: {"Message": "Invalid JSON primitive: paramval.", "StackTrace": "
in System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject () \ r \ n in System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal (Int32 depth) on System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasD Int32 depthLimit, JavaScriptSerializer serializer) \ r \ n in 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 in System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest (HttpContext context, JavaScriptSerializer serializer) \ r \ n on System.Web.Script.Services.RestHandler.GetRawParams (WebSata Method , HttpContext context) \ r \ n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall (HttpContext context, WebServiceMetho dData methodData) "," ExceptionType ":" System.ArgumentException "} Status: 500