【发布时间】:2009-12-26 07:22:36
【问题描述】:
使用环境:ASP.NET、jQuery
我有以下 AJAX 调用:
var tempVar = JSON.stringify({plotID:currentId});
$.ajax({
type: "POST",
url: "testPage.aspx/getPlotConfig",
data: tempVar,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$('#xDimLbl').text(msg.xDim);
$('#bDimLbl').text(msg.bDim);
}
});
后面的代码有方法getPlotConfig(string plotID)定义为
public static string getPlotConfig(string plotID)
{
string x = "T1";
string b = "T2";
return Json(new { xDim= x, bDim= b });
}
问题:
- 当我进行构建时,我收到错误:当前上下文中不存在名称 'Json' 哪个命名空间有问题?
- 连同两个字符串 x 和 b,我想返回一个哈希表,其键是字符串,值是逗号分隔的字符串列表。我该怎么做以及如何在客户端访问每个键值对?
干杯
【问题讨论】: