vue-cli中使用FormData实现表单异步提交
<form @submit.prevent="submit($event)"> <input type="text" class="form-control" placeholder="请输入姓名" name="cuserName">
·
<form @submit.prevent="submit($event)">
<input type="text" class="form-control" placeholder="请输入姓名" name="cuserName">
<input type="submit" value="立即注册" class="denglucon" />
</form>
submit: function(event) {
var formData = new FormData(event.target);
$.ajax({
type: "post",
url: that.service + "/register",
dataType: 'json',
contentType: false,
processData: false,
data: formData,
success: function(res) {
if(res.status != 200) {
alert(res.msg)
return false;
}
}
});
}
更多推荐
已为社区贡献9条内容
所有评论(0)