【发布时间】:2017-01-03 20:26:20
【问题描述】:
我有一个带有嵌套数组的 JSON 对象,我想将其发送到控制器。
这是我的 jQuery.ajax 调用:
$.ajax({
url: "@Url.Action("ExportJson")",
type: "POST",
data: JSON.stringify(myObj),
contentType:"application/json",
success: function (result) {
}
});
控制器:
public ActionResult ExportJson(string json)
{
return null;
}
为什么 json 字符串在控制器中返回为 null?而 console.log(JSON.stringify(myObj)) 在浏览器控制台中显示正确的对象。
【问题讨论】:
-
我只需要未创建 ViewModel 的原始 json 字符串
-
链接的问题中有答案,说明了如何做到这一点。例如,在第一个链接上:stackoverflow.com/a/21579180/215552
标签: javascript jquery json asp.net-mvc