jquery ajax提交json数据asp.net core3无法获得
Postman提交raw的JSON格式数据到后台方法可以正确读取,但是通过jQuery Ajax提交的json数据就无法正确!
后台方法的参数加了[FromBody]
$.ajax({
accepts: "application/json", //没有也不行
dataType: "json",//没有也不行
//请求地址
url: url1,
//请求方式
type: "POST",
//请求的媒体类型
contentType: "application/json",
//数据,json字符串 使用了JSON. stirngify也是不行
data: {
"Year": "2020",
"Month": "10",
"Dates": [
{
"Date": "2020-10-31T16:00:00.000Z",
"KeyOid": "8bad334e-34f6-4fd6-a2b2-fbda3cb8826a",
"IsHoliday": true
}
]
},
//请求成功
success: function (res) {
dataloading = false;
console.log(res);
},
//请求失败,包含具体的错误信息
error: function (err) {
dataloading = false;
console.log(err);
}
});
求大神指导!