У меня есть этот Ajax-вызов к webMethod
$.ajax({
type: "post",
url:"Default.aspx/MessagesCount",
data: ko.toJSON({ tasks: self.tasks }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
var msg = $.parseJSON(result.d);
alert(msg.Tasks[0].title)
},
error: function (resultx) { alert(resultx); }
});
отправка данных и объект со следующими значениями
{"tasks":[{"title":"PRIVMSG001"},{"title":"PRIVMSG002"},{"title":"PRIVMSG003"},{"title":"PRIVMSG004"},{"title":"PRIVMSG005"},{"title":"PRIVMSG006"}]}
Веб-метод
<WebMethod()> _
Public Shared Function MessagesCount(ByVal tasks As Object) As String
'How to handle tasks object, using it properties, values exc.
'Testing return dum json
Return "{""Tasks"": [{""title"": ""PRIVMSG001""},{""title"": ""PRIVMSG002""},{""title"": ""PRIVMSG003""}]}"
End Function
Как обрабатывать объект, отправленный клиентом на сервер, нужно уметь использовать эти значения и свойства.
Спасибо