2010-10-12 78 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}}