【发布时间】:2019-09-22 15:29:28
【问题描述】:
我在使用 jquery 在 sweetalert2 中提交表单时遇到问题。
这是我的代码:
<?=form_open_multipart('controller_path','id="form_service"' , ''?>
<input type="button" name="update" id="submit-operate" value="Submit To Operated" class="btn btn-success" onclick="service.submitService()"/>
<?= form_close(); ?>
这是 service.js:
submitService: function(){
swal({
title: 'Are you sure?',
text: "You will submit this service to the next phase",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Submit'
}).then((result) => {
if (result.value) {
$("#form_service").submit()
}
});
}
sweetalert 也可以,当我在if(result.value) 中执行console.log 时,它会显示在控制台上,但表单没有提交。有人可以告诉我正确的方法吗?谢谢。
【问题讨论】:
-
@AnusAhmad 谢谢,但它仍然不起作用..
标签: javascript jquery html sweetalert2