2010-10-12 51 views

回答

7

我所知,你可以返回XML或JSON。

要返回JSON添加此注释或你的方法:

[ScriptMethod(ResponseFormat = ResponseFormat.Json)] 

并在您的类允许ScriptService

[ScriptService] 

一个例子:

[ScriptMethod(ResponseFormat = ResponseFormat.Json)] 
public Dictionary<string, object> Test() 
{ 
    var ret = new Dictionary<string, object>(); 
    ret.Add("Test", 1); 
    return ret; 
} 

// result: 
{d:{Test:1}}