我对webMethod
进行了Ajax调用$.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
如何处理客户端在服务器上发送的对象,需要能够使用这些值和属性。
由于