我有一个字符串化的JSON对象,它在警报中正确显示,在浏览器调试器的post部分正确显示,,但在控制器中显示为null。我不确定它是怎么丢失信息的。
以下是JS代码:
var assessmentStatus = [];
$("select.assessmentSelect").each(function () {
assessmentStatus.push({
assessmentname: $(this).attr("id"),
assessmentstatus: $(this).val()
});
});
alert(JSON.stringify(assessmentStatus));
$.ajax({
url: @Url.Action("testAS") ,
type: "POST",
contentType: application/json ,
data: JSON.stringify({
AS: assessmentStatus,
AS2: assessmentStatus
})
});
这是警报中显示的内容:
[{"assessmentname":"testassessment","assessmentstatus":"Design"},{"assessmentname":"DepressionUpload","assessmentstatus":"Design"}]
这是帖子中出现的内容:
[Object { assessmentname="testassessment", assessmentstatus="Design"}, Object { assessmentname="DepressionUpload", assessmentstatus="Design"}]
我的控制器看起来像这样:
public ActionResult testAS (string[] AS, string AS2)
string[] AS returns [0]null [1]null
string AS2 just returns null.
为什么它在发送到控制器时没有被字符串化?