Asp.Net Core MVC传值 Asp.Net Core API 前台写法

$("#Add_User").click(function () {
var obj = {
 //"属性名": 传递的值,
"User_Name": $("#User_Name").val(),
"User_PassWord": $("#User_PassWord").val(),
"User_Email": $("#User_Email").val(),
"User_Phone": $("#User_Phone").val(),
"User_Card": $("#User_Card").val()
};
$.ajax({
url: "默认地址/api/控制器方法/动作方法名,
type: "post",
dataType: "json",
data: obj,
accepts: "application/x-www-form-urlencoded",  //非加不可
contentType: "application/x-www-form-urlencoded",  //非加不可
success: function (data) {
console.log(data);
if (data > 0) {
alert('添加成功!');
} else {
alert('添加失败!');
}
}
});

posted @ 2020-06-06 09:12  小浩~  阅读(319)  评论(0编辑  收藏  举报