[英]Cannot submit form using jquery
我在使用 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
时,它会显示在控制台上,但表单没有提交。 有人可以告诉我正确的方法吗? 谢谢你。
尝试这个:
submitService = function(){
var form = $("#form_service");
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.submit(); //semicolon in the end
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.