I have a list of objects in JavaScript which I need to pass to ASP.NET WebService.
Currently I include ScriptManager into my page:
<asp:ScriptManager runat="server">
<Services>
<asp:ServiceReference Path="/ws_data.asmx" />
</Services>
</asp:ScriptManager>
declare WebMethod:
[WebMethod(true)]
public object SaveData(my_package.MyObject[] objects)
{
// ...
}
And call the method from JavaScript:
var parameters = '['+
+ '{"PlayerId":11, "Pos":12, "Flang":13"},'
+ '{"PlayerId":21, "Pos":22, "Flang":23"}'
+ ']';
ws_data.SaveData(parameters, OnComplete, OnError, OnTimeOut);
When method is called, i receiver 'OnError' called with error message:
Cannot convert object of type 'System.String' to type 'my_package.MyObject[]'
What is wrong in my code?
I'm not too experienced with neither of used technologies (JSON, web services, JavaScript) and lost in different assumption.
Please advise, any help is welcome!
P.S. Changed formatting to match JSON specification (advised by codenoire):
var parameters = [
{"PlayerId":11, "Pos":12,"Flang":13},
{"PlayerId":21, "Pos":22,"Flang":23 }
];
That helped to make workable simplified case when only 1 object is passed, but passing an array still gives the same error.