私は単純なウェブメソッドを持っています:
<WebMethod(Description:="Does something.")> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Shared Function ReturnJSONData() As Person
Dim guy As New Person
guy.Name = "Joe"
guy.Age = 8
Return guy
End Function
そして、ここで ajax メソッドを呼び出しています。
function GetPerson() {
PageMethods.ReturnJSONData(OnWSRequestComplete1);
}
function OnWSRequestComplete1(result) {
alert(result.d);
}
firebug などのツールを使用すると、JSON の結果を確認できます。
{"d":{"__type":"Person","Name":"Joe","Age":8}}
ただし、「alert(result.d)」を呼び出すと、未定義になります。何か不足していますか?