2 回答

TA贡献1811条经验 获得超6个赞
[FromBody]
在动作计上使用
[HttpPost] public async Task<IActionResult> Index([FromBody] MyModel model)

TA贡献1799条经验 获得超6个赞
我您的要求不限于使用jQuery,因为您已经在使用它。更好地使用jQuery方法进行API调用,因为它还将解决跨浏览器兼容性问题。
这是一个例子。
// this is the id of the form
$("#idForm").submit(function(e) {
e.preventDefault(); // avoid to execute the actual submit of the form.
var form = $(this);
var url = form.attr('action');
$.ajax({
type: "POST",
url: url,
data: form.serialize(), // serializes the form's elements.
success: function(data)
{
alert(data); // show response from the php script.
}
});
});
顺便说一句,这就是jquery调用后实现的AJAX调用看起来像您可以使用它的样子。
添加回答
举报