I need to pass a simple Javascript array to my wcf ajax webservice:
var array = new Array();
array["ParamA"] = "xyz";
array["12344"] = "9";
myNamespace.DoSomething(array);
This this my WCF method:
[OperationContract]
[WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
public void DoSomething(object values)
“values” is an empty array when it is called from javascript with my values.
What is the best approach to pass a simple list of KeyValuePairs to my webservice?
I was able to find the solution myself:
must be called in javascript like this:
var params = [{ “Key”: “A”, “Value”: 5}, { “Key”: “B”, “Value”: “Test}]
This can of course be simplified: