这可能是指
Json
ASP.NET MVC控制器中使用的方法。作为你
getPlotConfig
函数是静态的,不能使用此方法。你可以看看
PageMethods
. 下面是一个例子:
[WebMethod]
[ScriptMethod]
public static object getPlotConfig(string plotID)
{
var hash = new Dictionary<string, string>()
{
{ "key1", "valueA,valueB" },
{ "key2", "valueC,valueD" },
};
var x = "T1";
var b = "T2";
return new { xDim = x, bDim = b, hash = hash };
}
在javascript中:
success: function(msg) {
$('#xDimLbl').text(msg.d.xDim);
$('#bDimLbl').text(msg.d.bDim);
for(var key in msg.d.hash) {
var value = msg.d.hash[key];
// Do something with key and value...
}
}