【发布时间】:2023-03-27 08:30:01
【问题描述】:
> 我.net core 2.2 这个是object Object:
[Serializable]
public class oob
{
public int i { get; set; }
public string j { get; set; }
}
这是名为 Gett 的“Home”控制器中的操作,它将 oob 作为 ajax 的输入
[HttpGet]
public IActionResult Gett(oob ww)
{
return Ok(ww);
}
阿贾克斯
{
$.ajax({
type: "Get",
url: "Home/gett",
data: { ww: JSON.stringify({i:55,j:"weqe"})},
dataType: "json",
contentType:"json",
success: function (f) {
console.log(f);
},
error: function (f) {
console.log(f);
}
});
});
当发出请求时,在 Gett(oob ww) 我得到一个值为 i=0 且 j=null 的对象
【问题讨论】:
-
你的意思是:返回 Ok(ww) 而不是 OK(i)。对吗?
-
对不起@阿卜杜拉迪巴斯
-
试试 ContentType 'application/json'
标签: c# jquery .net ajax asp.net-core-mvc