C# mvc+jquery post 提交 后台 action 获取不到值 值为nulll

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C# mvc+jquery post 提交 后台 action 获取不到值 值为nulll相关的知识,希望对你有一定的参考价值。

C# mvc+jquery post 提交 后台 action 获取不到值 值为nulll
代码如下
前台页面
var ddd = function ()
$.post("/Home/ttt", "d": 1 , function (result) alert(result); , 'json');

$.ajax(
type: "POST",
url: "/Home/ttt",
data: "d": 1, ,
dataType: "json",
success: function (data)
alert(data);
,
error: function (json)
alert("订单取消异常,请刷新后重试...");

);

;
后台 action
[HttpPost]
public JsonResult ttt(string d)

string sd = Request.QueryString["d"];
return Json(new f = 1 );
//return View();

参考技术A 是的
MVC参数(基本类型)接收只能是get
你要获取post的数据必须封装成对象

不封装就要从Form里取值取到

以上是关于C# mvc+jquery post 提交 后台 action 获取不到值 值为nulll的主要内容,如果未能解决你的问题,请参考以下文章